繁体   English   中英

聚合物dom-如果不起作用

[英]Polymer dom-if not working

如果使用Polymer 1.X,我有此模板dom-,但无法正常工作。

它应该显示“正在载入”当requirement.allLoadedfalse时,并显示真正的内容requirement.allLoadedtrue

我在测试函数中切换此变量的状态。 但这并没有效果。

 //Properties requirement: { type:Object, value: { allLoaded: false, tagsLoaded: false } } //Test function _testButton: function(){ console.log(this.requirement); this.requirement.allLoaded = !this.requirement.allLoaded; console.log(this.requirement); }, 
 <div id="modal-content"> <template is="dom-if" if={{!requirement.allLoaded}}> <p>Loading</p> </template> <template is="dom-if" if={{requirement.allLoaded}}> <iron-pages selected="[[selectedTab]]" attr-for-selected="name" role="main"> <details-tab name="details"></details-tab> <bar-chart-tab name="barchart"></bar-chart-tab> <live-data-tab name="livedata" shared-info='{{sharedInfo}}'></live-data-tab> </iron-pages> </template> </div> 

注意:我已经使用此结构来显示/不显示其他项目(使用Polymer 2),并且它正在工作。

仅仅是改变不起作用? 即它可以正确显示负载?

尝试通知聚合物更改: this.requirement.allLoaded = !this.requirement.allLoaded; this.notifyPath('requirement.allLoaded'); this.requirement.allLoaded = !this.requirement.allLoaded; this.notifyPath('requirement.allLoaded');

您还可以将this.set('property.subProperty', value)用于可观察的更改
在您的情况下,这是this.set('requirement.allLoaded', !this.requirement.allLoaded);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM