在我的dom-moule中,我想使用绑定(bind)数据ticket.start_time
作为函数的输入并显示函数返回(即从 ticket.start_time
到现在耗时)。
目前,我只知道如何访问绑定(bind)数据,如下
<li><span>{{ticket.start_time}} has lapsed</span>
缺少的部分是
- 如何访问
ticket.start_time
来自函数 - 如何触发该功能
完整代码在这里:
<dom-module id="todo-app">
<template>
<ul>
<template is="dom-repeat" items="[[reply.tickets]]" as="ticket">
<style>
span[done]{
text-decoration: line-through;
}
</style>
<li><span done$={{ticket.end_time}}>{{ticket.id}}: {{ticket.detail}}, {{ticket.start_time}} has lapsed</span>
</template>
</template>
</ul>
<iron-ajax
auto=true
id="requestData"
url="/data"
handleAs="json"
on-response="handleResponse">
</iron-ajax>
</template>
<script>
Polymer({
is: "todo-app",
properties: {
reply: {
type: Object
}
},
handleResponse: function (data){
this.reply= data.detail.response;
}
});
</script>
</dom-module>
最佳答案
试试这个
<span>{{myFunc(ticket.start_time)}}</span>
...
<script>
myFunc:function(item){
//some code
return value
}
关于javascript - 如何使用绑定(bind)数据作为 polymer 中的函数输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41322674/