我正在尝试聚合物,但无法使其成为一个简单的组件。基于文档。我做了以下事情
添加了 webcomponents.js,导入了polymer.html,并创建了一个简单的 helloworld 组件,无需任何脚本。我可以看到 DEV 工具中加载的所有内容,但 helloworld 组件中未创建 shawdow 根。
聚合物版本为“聚合物”:“聚合物/聚合物#~1.0.5”
下面是 hello world 代码。
<polymer-element name="hello-world" noscript>
<template>
<h1>Hello World</h1>
</template>
</polymer-element>
但是 helloworld 中没有影子根。
我在这里做错了什么。
最佳答案
您正在使用 Polymer v1.0,但您似乎没有按照该版本应有的方式声明您的元素。请参阅here :
<dom-module id="hello-world">
<style>
/* CSS rules for your element */
</style>
<template>
<!-- local DOM for your element -->
<h1>Hello world</h1>
</template>
<script>
// element registration
Polymer({
is: "hello-world"
});
</script>
</dom-module>
关于javascript - 聚合物简单组件不工作 - 一切都已加载,但没有影子根,没有错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31140305/