簡體   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