聚合物简单组件不工作 - 一切都已加载但没有阴影根,没有错误
Polymer Simple Component Not working - Everything is loaded but No Shawdow Root, No Error
我正在试用聚合物,但无法使其成为一个简单的组件。基于文档。我做了以下事情
添加了 webcomponents.js,导入了 polymer.html 并创建了一个没有任何脚本的简单 helloworld 组件。我可以看到 DEV 工具中加载的所有内容,但 shawdow 根目录并未在 helloworld 组件中创建。
聚合物版本为 "polymer":"Polymer/polymer#~1.0.5"
下面是 hello world 代码。
<polymer-element name="hello-world" noscript>
<template>
<h1>Hello World</h1>
</template>
</polymer-element>
但是helloworld没有shadow root
我在这里做错了什么。
您使用的是 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>
我正在试用聚合物,但无法使其成为一个简单的组件。基于文档。我做了以下事情
添加了 webcomponents.js,导入了 polymer.html 并创建了一个没有任何脚本的简单 helloworld 组件。我可以看到 DEV 工具中加载的所有内容,但 shawdow 根目录并未在 helloworld 组件中创建。
聚合物版本为 "polymer":"Polymer/polymer#~1.0.5"
下面是 hello world 代码。
<polymer-element name="hello-world" noscript>
<template>
<h1>Hello World</h1>
</template>
</polymer-element>
但是helloworld没有shadow root
我在这里做错了什么。
您使用的是 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>