【发布时间】:2017-04-07 05:11:25
【问题描述】:
我刚刚尝试使用 javascript 将我的钩子放入 nativescript 并且有一个非常基本的问题:
let costFormatter= {
toView(value){
console.log('Got:' + value);
return '$' + value;
},
toModel(value){
console.log('Got:' + value);
return '$' + value;
}
};
http.getJSON("<My API Call>").then(function (r){
page.bindingContext = {
deals: r,
costFormatter:costFormatter
};
}, function (e){
//// Argument (e) is Error!
//console.log(e);
});
在上面的代码中,我定义了成本格式化程序,我只想在我的列表视图标签上的每个销售价格的价格旁边添加一个 $。渲染列表视图我使用:
<ListView id="SteamItems" items="{{ deals }}">
<ListView.itemTemplate>
<GridLayout columns="*, *, 50, 50" rows="50, 50, auto, *">
<Image src="{{ thumb }}" row="0" col="0" cssClass="thumb"/>
<Label text="{{ title }}" key="1" row="0" col="1" cssClass="title"/>
<Label text="{{ normalPrice|costFormatter }}" key="2" row="0" col="2" cssClass="normal-price"/>
<Label text="{{ salePrice|costFormatter }}" key="3" row="0" col="3" cssClass="sale-price"/>
</GridLayout>
</ListView.itemTemplate>
</ListView>
我不明白为什么我得到了
JS: Cannot find function or filter: costFormatter
对于我的 nativescript 终端中的列表视图中的每一行。我做错了什么?
【问题讨论】:
标签: javascript android nativescript