在聚合物元素内动态创建 html 导入
有谁知道如何将 html 导入动态添加到聚合物元素(1.0 版)中?
下面的代码似乎不起作用,并抱怨..
HTML element <link> is ignored in shadow tree.
有谁知道解决这个问题或知道更好的方法?
<!-- here is where the created import could go -->
<dom-module id="my-component">
<!-- here is where I'd ideally like the import to be created -->
<template>
<div id="container">
<!--This is where my dynamically loaded element should be placed-->
</div>
</template>
<script>
Polymer({is:'my-component',
attached: function(){
var importElem = document.createElement('link');
importElem.rel = 'import';
importElem.href = '/components/my-dynamic-sub-component.html';
this.root.appendChild(importElem);
var app = document.createElement('my-dynamic-sub-component');
this.$.container.appendChild(app);
}
});
</script>
</dom-module>