1
我有被注入並存儲使用以下行的元素:聚合物1.x中刪除元素通過變量參考
this._lastPromo = this.$$('#inject-point').appendChild(promo);
我現在需要在以後的時間在我的codebase.I刪除此元素曾嘗試以下2種情況:
this.$$('#inject-point').removeChild(this._lastPromo);
和:
this._lastPromo.parentNode.removeChild(this._lastPromo);
我收到以下錯誤:
Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
和:
Uncaught TypeError: Cannot read property 'removeChild' of null
問: 如何從文檔中刪除此特定元素?
該代碼看起來不錯,你可以提供一些更多的代碼或一個JS斌,所以我們可以看到發生了什麼? – JohnRiv
可能你有具體的情況,但只是要提到,在聚合物推薦的操縱DOM的方式是通過操縱數據:http://stackoverflow.com/a/38950936/986212 –