【发布时间】:2019-04-26 14:52:50
【问题描述】:
我又迷路了,试图在翡翠模板中做一些简单的计算。
给定这个数据对象:
{
"trade": {
"name": "Mogens",
"dst_currency": "EUR",
"dst_value": 115.7,
"src_price": null,
"src_value": 2,
"src_currency": "XMR",
"date": null
}
}
还有这个哈巴狗来源:
table
thead
tr
th Currency
th Quantity
th Price
th Total
th Date
tbody
tr
script.
if (trade.dst_currency === "EUR")
trade.src_price = trade.dst_value / trade.src_value
else
trade.src_price = Number(trade.src_value) / Number(trade.dst_value)
th.align-middle #{trade.dst_currency}
th.align-middle #{trade.dst_value}
th.align-middle= #{trade.src_price}
th.align-middle #{trade.src_value} #{trade.src_currency}
th.align-middle #{trade.date}
if trade.name === "Bob"
h1 Hello Bob
else
h1 My name is #{trade.name}
如果可能的话,如何做到这一点?我错过了什么?
【问题讨论】:
标签: javascript pug