我想动态添加属性 id 到标签,但它给出了错误
“Uncaught ReferenceError: Unable to process binding “attr: function (){return {id:id} }”消息:id is not defined”
我的html-
<label data-bind="text:label"></label>
<span class="name" data-bind="attr:{id:id},html:value"></span>
<span class="cancelled" data-bind="html:cancel"></span>
<span class="currency-block" data-bind="html:amount"></span>
我的视图模型-
this.listrows = [
{layout:'basic', params:{icon:'icon-phone', items:[
{item:'content', type:'basic', params:{id:'test', label:'From Account',value:'asuhdas'}}
]}},
{layout:'basic', params:{icon:'icon-money', items:[
{item:'content', type:'basic', params:{label: 'To Account:', value:''}}
]}}
]
我添加了 attr:{id:id} 仍然是它的错误。任何人都可以帮助我。