我正在尝试使用聚合物,但无法使其成为一个简单的组件。基于文档。我做了以下事情
添加了webcomponents.js,导入了polymer.html,并创建了一个没有任何脚本的简单helloworld组件。我可以看到DEV工具中加载的所有内容,但是helloworld组件中未创建shawdow根。
聚合物版本为“聚合物”:“聚合物/聚合物#〜1.0.5”
下面是您好世界代码。
<polymer-element name="hello-world" noscript>
<template>
<h1>Hello World</h1>
</template>
</polymer-element>
但是helloworld中没有任何影子根源。
我在这里做错什么了。
您正在使用Polymer v1.0,但似乎并未按照该版本的方式声明元素。看这里:
<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>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句