谁能告诉我如何根据 Polymer 属性的值导入元素?我以为我可以使用数据绑定,但是......它不起作用。是否可以动态导入元素?
这里的代码示例:
<link rel="import" href="app-window/{{name}}-app.html">
//This was my first idea (obviously doesn't work)
<polymer-element name="window-base" attributes="name" >
<template>
<link rel="stylesheet" href="window-base.css">
<section id="app">
<!--here will go the instance-->
</section>
</template>
<script>
Polymer('window-base', {
name: "Finder",
ready: function () {
this.instanceApp();
},
instanceApp: function () {
//this depends on the import made
var app=document.createElement(this.name + "-app");
this.$.app.appendChild(app);
}
});
</script>
</polymer-element>
谢谢!