我的 Index.html 中有以下代码:
<body unresolved>
<template is="dom-bind" id="app">
<span>[[userContext.Name]]</span>
</template>
<script>
(function(document) {
'use strict';
var app = document.querySelector('#app');
app.userContext = { Name: "Test" };
})(document);
</script>
</body>
这工作正常!
但是当我现在像这样刷新 UserContext 时:
app.userContext = { Name: "Hallo" };
页面未更新
有办法刷新绑定(bind)吗?
最佳答案
您需要使用 Polymer 数据绑定(bind) API 方法,例如 set
app.set('userContext.Name', 'Test');
另请参阅https://www.polymer-project.org/1.0/docs/devguide/data-binding.html#set-path
关于javascript - polymer "DOM-Bind"更新绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34239603/