问题描述
我是polymer的新手,当我更改父级的值时尝试更新一个子级,这是我的代码段。我不确定我到底在做什么错,但是每次我更新父项中的值时,不会调用子函数。仅在第一次创建孩子时才调用它。任何建议将不胜感激。
// Parent javascript
properties: {
buttonState_: {
type: Object,value: {
'back': 'some value','next' : 'another value'
},}
},onSomeAction_() {
// when this action happens update the bottonState_ property and notify child
this.set(
'buttonState_.next',"new value");
},//child javascript
properties: {
buttonState: Object,},isButtonHidden_(buttonName,buttonState_) {
// this never gets called
return buttonState_[buttonName] === "check value"
},
<!--Parent html-->
<button-bar button-state="[[buttonState_]]">
<!--- Child html -->
<cr-button id="next"
class="action-button"
on-click="onNextButtonClicked_"
disabled="[[isButtondisabled_('next',buttonState)]]"
hidden$="[[isButtonHidden_('next',buttonState)]]">
[[i18n('next')]]
</cr-button>
e`
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)