Uncaught NotSupportedError: Failed to execute 'registerElement' on 'Document': Registration failed for type 'paper-button'
Uncaught NotSupportedError: Failed to execute 'registerElement' on 'Document': Registration failed for type 'paper-button'
我正在使用 Polymer 1.2.1
我正在尝试创建两个聚合物元素 paper-button 和 paper-input。
我在 head 中导入了 following
<script src="third-party/js/bower/webcomponentsjs/webcomponents-lite.min.js"></script>
<link rel="import" href="third-party/html/bower/polymer/polymer.html">
<link rel="import" href="third-party/html/bower/paper-button/paper-button.html">
<link rel="import" href="third-party/html/bower/paper-input/paper-input.html">
并在正文中添加了以下内容
<paper-button>Flat button</paper-button>
<paper-button raised>Raised button</paper-button>
<paper-button noink>No ripple effect</paper-button>
<paper-button toggles>Toggle-able button</paper-button>
<paper-input label="total">
<div prefix>$</div>
<paper-icon-button suffix icon="clear"></paper-icon-button>
</paper-input>
<script>
Polymer({
is: "paper-button",
// add a callback to the element's prototype
created: function() {
console.log("inside pol1");
this.textContent = "I'm a proto-element!"
}
});
Polymer({
is: "paper-input",
// add a callback to the element's prototype
created: function() {
console.log("inside pol2");
this.textContent = "I'm a proto-elemente2!"
}
});
</script>
I'm expecting a change in text of respective elements with some console but none of these happens. I get an error saying
"Uncaught NotSupportedError: Failed to execute 'registerElement' on 'Document': Registration failed for type 'paper-button'. A type with that name is already registered."
我不太确定你想达到什么目的,但你的问题的答案是这样的:
您的 paper-input
和 paper-button
已经通过 <head>
部分中的 <link rel="import">
标签注册到 Polymer 中,所以当您尝试 重新注册他们使用Polymer({is:"paper-button"...})
,失败...
我也不建议覆盖打包元素的 created()
回调 - 如果您想执行自己的自定义任务,请创建一个 包装 您的新自定义元素目标元素,然后改为调用您的新元素。
我正在使用 Polymer 1.2.1 我正在尝试创建两个聚合物元素 paper-button 和 paper-input。
我在 head 中导入了 following
<script src="third-party/js/bower/webcomponentsjs/webcomponents-lite.min.js"></script>
<link rel="import" href="third-party/html/bower/polymer/polymer.html">
<link rel="import" href="third-party/html/bower/paper-button/paper-button.html">
<link rel="import" href="third-party/html/bower/paper-input/paper-input.html">
并在正文中添加了以下内容
<paper-button>Flat button</paper-button>
<paper-button raised>Raised button</paper-button>
<paper-button noink>No ripple effect</paper-button>
<paper-button toggles>Toggle-able button</paper-button>
<paper-input label="total">
<div prefix>$</div>
<paper-icon-button suffix icon="clear"></paper-icon-button>
</paper-input>
<script>
Polymer({
is: "paper-button",
// add a callback to the element's prototype
created: function() {
console.log("inside pol1");
this.textContent = "I'm a proto-element!"
}
});
Polymer({
is: "paper-input",
// add a callback to the element's prototype
created: function() {
console.log("inside pol2");
this.textContent = "I'm a proto-elemente2!"
}
});
</script>
I'm expecting a change in text of respective elements with some console but none of these happens. I get an error saying
"Uncaught NotSupportedError: Failed to execute 'registerElement' on 'Document': Registration failed for type 'paper-button'. A type with that name is already registered."
我不太确定你想达到什么目的,但你的问题的答案是这样的:
您的 paper-input
和 paper-button
已经通过 <head>
部分中的 <link rel="import">
标签注册到 Polymer 中,所以当您尝试 重新注册他们使用Polymer({is:"paper-button"...})
,失败...
我也不建议覆盖打包元素的 created()
回调 - 如果您想执行自己的自定义任务,请创建一个 包装 您的新自定义元素目标元素,然后改为调用您的新元素。