script
标记创建,但这不是本主题的一部分。 style
标签不是最小结构的一部分,但它只是为了理解目的而保留在那里。 js
文件,其中包含至少上面编写的代码,然后在元素中引用它。 id
的dom-module
,并is
财产Polymer constructor
应该总是一样的。 版 | 发布日期 |
---|---|
V1.6.0 | 2016年6月29日 |
V1.5.0 | 2016年5月31日 |
V1.4.0 | 2016年5月18日 |
V1.0.0 | 2015年5月27日 |
定义没有内容的元素。
<dom-module id="empty-element">
<template>
<style>
</style>
</template>
<script>
Polymer({
is: 'empty-element',
});
</script>
</dom-module>
然后您可以在任何其他页面中使用新元素。
<!DOCTYPE html>
<html>
<head>
<!-- Using lite version as Polymer does not require Polyfill for Shadow Dom -->
<script src="path/to/bower_components/webcomponentsjs/webcomponents-lite.min.js"></script>
<!-- Importing the element assuming file name is also empty-element.html -->
<link rel="import" href="empty-element.html">
</head>
<body>
<empty-element></empty-element>
</body>
</html>