bil*_*raw 3 javascript polymer
我正在使用Polymer 0.9,我有这个模板.
<template>
<ul>
<template is="dom-repeat" items="{{menuPages}}">
<li class="c-text">
<span>{{item.title}}</span>
</li>
</template>
</ul>
</template>
Run Code Online (Sandbox Code Playgroud)
当我使用此代码段更新数据时,它不会加载
ready: function () {
this.menuPages.push({title:'hey'});
this.menuPages.push({title:'hey2'});
}
Run Code Online (Sandbox Code Playgroud)
然而这是有效的
ready: function () {
this.menuPages = [{title:'hey'}, {title:'hey2'}];
}
Run Code Online (Sandbox Code Playgroud)
Zik*_*kes 14
为了触发DOM更新,您必须使用以下内容:
this.push('menuPages', {title:'hey'});
Run Code Online (Sandbox Code Playgroud)
文档:https://www.polymer-project.org/1.0/docs/devguide/templates.html#dom-repeat
| 归档时间: |
|
| 查看次数: |
1936 次 |
| 最近记录: |