JADE中的算术运算符 [英] Arithmetic operators in JADE

查看:71
本文介绍了JADE中的算术运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Jade模板引擎与NOde.js一起使用. 我有两个变量:

I'm using Jade template engine with NOde.js. I have two variables:

a = 0.0378
b = 0.1545

我在玉器中做

- var result = a + b*2

当我执行#{result}

0.03780.309

似乎将数字连接为字符串. 有人可以告诉我如何在Jade中使用算术运算符吗?

It seems to concatenate the numbers as strings. Could someone tell me how can I use arithmetic operators in Jade?

谢谢

推荐答案

您确定a(也是b)是数字而不是字符串吗?

Are you sure that a (and also b) is a number and not a string?

如果是字符串,则需要通过parseFloat将其转换为数字:

If it is a string you will need to to convert it to a number via parseFloat:

- var result = parseFloat(a)+parseFloat(b)*2

这篇关于JADE中的算术运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆