我创建了2个按钮。两者都有相同的点击。第一个是通过在div中编写html按钮创建的。这个有效。第二个是通过使用内部-h-t-m-l属性返回按钮的空div创建的。这个不起作用。为什么呢?
<link rel="import" href="bower_components/polymer/polymer-element.html">
<link rel="import" href="bower_components/paper-button/paper-button.html">
<dom-module id="x-custom">
<template>
<div inner-h-t-m-l="[[getButton()]]"></div>
<div><paper-button on-click='didClick'>Does Work</paper-button></div>
</template>
<script>
class XCustom extends Polymer.Element {
static get is() {
return 'x-custom';
}
static get properties() {
return {}
}
getButton() {
return "<paper-button on-click='didClick'>Does Not Work</paper-button>";
}
didClick() {
alert("Did Click");
}
}
customElements.define(XCustom.is, XCustom);
</script>
</dom-module>