【发布时间】:2018-06-29 11:11:19
【问题描述】:
我正在学习如何使用Polymer。我按照指示完全正确 here,但在第3步添加paper-checkbox的导入后出现错误:
错误:一个名为“iron-meta”的自定义元素已经被 已定义。
(此错误出现在浏览器内控制台中)。
此外,使用paper-checkbox 的页面无法加载,并且是完全空白的,而其他页面(例如视图一、视图二等)加载完全正常。
我开始了一个全新的项目并再次按照指示进行操作,但发生了同样的问题。什么可能导致此问题?
这是页面未加载时的屏幕截图。可以看到,导航窗格和页眉仍然存在,但是随着页面的变化而变化的内容是空白的:
这里是my-new-view.js:
/* Load the PolymerElement base class and html helper function */
import { PolymerElement, html } from '@polymer/polymer/polymer-element.js';
import '@polymer/paper-checkbox/paper-checkbox.js';
/* Load shared styles. All view elements use these styles */
import './shared-styles.js';
/* Extend the base PolymerElement class */
class MyNewView extends PolymerElement {
/* Define a template for the new element */
static get template() {
return html`
<style include="shared-styles">
:host {
display: block;
padding: 10px;
}
</style>
<div class="card">
<div class="circle">1</div>
<h1>New View</h1>
<paper-checkbox>Ready to deploy!</paper-checkbox>
<p>New view!</p>
</div>
`;
}
}
/* Register the new element with the browser */
window.customElements.define('my-new-view', MyNewView)
;
【问题讨论】:
-
你能分享你的 my-new-view.js 吗?
-
我更新了我的代码
标签: javascript npm polymer