[英]Jade not rendering external JSON
I have a jade template that should list all possible solutions to the QPX Express search request: 我有一个翡翠模板,该模板应列出QPX Express搜索请求的所有可能解决方案:
{ kind: 'qpxExpress#tripsSearch',
trips:
{ kind: 'qpxexpress#tripOptions',
requestId: 'RwDOf6HXVDvvn6nBm0PNpw',
data:
{ kind: 'qpxexpress#data',
airport: [Object],
city: [Object],
aircraft: [Object],
tax: [Object],
carrier: [Object] },
tripOption: [ [Object], [Object], [Object] ] } }
However, I'm trying to render the above the view but I keep getting this error: 但是,我正在尝试渲染上面的视图,但我不断收到此错误:
Cannot read property 'tripOption' of undefined
Template 模板
block content
.ui
for data in result
.ui_box
.ui_box__inner
.event
span #{data.trips.tripOption[].saleTotal}
Route 路线
router.get('/', function(req, res, next) {
api.apiGet(function (data) {
console.log(data) //THIS WORKS
res.render('index', {result: data})
})
})
All the code is looking right to me and I'm working off properties from the API documentation . 所有代码对我来说都很合适,我正在研究API文档中的属性。 Can anyone point me in the right direction to debug?
谁能指出我正确的调试方向?
Update: 1 更新:1
To display saleTotal
from array of tripOption
, change your jade template like the below one, 要显示
saleTotal
数组中的tripOption
,请更改您的玉器模板,如下所示,
block content
.ui
for data in result
.ui_box
.ui_box__inner
.event
each trip in data.trips.tripOption
span #{trip.saleTotal}
In your code, span #{data.trips.tripOption[].saleTotal}
在您的代码中,
span #{data.trips.tripOption[].saleTotal}
if data
refers to JSON content then change your span bindings like this 如果
data
引用JSON内容,则像这样更改跨度绑定
span #{data.trips.data.tripOption[].saleTotal}
else span #{data.tripOption[].saleTotal}
span #{data.trips.data.tripOption[].saleTotal}
否则span #{data.tripOption[].saleTotal}
Because tripOption
is avaiable in data
object not in trips
因为
tripOption
在data
对象中可用而不在trips
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.