动态将页面添加到聚合物铁页面 [英] Dynamically add page to Polymer iron-pages
本文介绍了动态将页面添加到聚合物铁页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有什么办法可以动态地将新页面添加到铁页面?我有这个铁页:
Is there any way to add a new page to iron-pages dynamically? I have this iron-pages:
<iron-pages selected="0">
<div>Abc</div>
</iron-pages>
然后我动态添加更多页面:
And then I add a couple more pages dynamically:
document.addEventListener("WebComponentsReady", function() {
var newDiv = document.createElement("div");
newDiv.innerHtml = "Def";
var ironPage = document.querySelector("iron-pages");
ironPage.appendChild(newDiv);
console.log(ironPage.items.length) // log 1 instead of 2
ironPage.select(1) // nothing shown.
});
推荐答案
您可能需要使用Polymer.Dom Api
you might need to use the Polymer.Dom Api
Polymer.dom(ironPage).appendChild(newDiv);
另外,我认为您可能又犯了一个错误:
Also I think you may have made another error:
代替
newDiv.innerHtml = "def";
做
newDiv.textContent = "def";
这篇关于动态将页面添加到聚合物铁页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文