【发布时间】:2017-02-04 16:57:22
【问题描述】:
在 my-app.html 中
...
<paper-icon-button icon="my-icons:menu" onclick="this.$._joesDrawerToggle()"></paper-icon-button>
...
<script>
Polymer({
is: 'my-app',
...
_showPage404: function() {
this.page = 'view404';
},
_joesDrawerToggle: function () {
if (this.$.drawer.opened) {
this.$.drawer.close();
}else{
this.$.drawer.open();
}
}
});
</script>
编辑 my-app.html 时,WebStorm 自动完成 finds this.$._j as this.$._joesDrawerToggle()
但是,当我点击按钮时,Chrome 开发工具会说:
Uncaught TypeError: this.$._joesDrawerToggle is not a function
at HTMLElement.onclick ((index):1)
onclick @ (index):1
似乎 index.html 需要了解 _joesDrawerToggle()。我不确定为什么。
我怎样才能做到这一点?
【问题讨论】:
标签: javascript html scope polymer-starter-kit