我试图看看聚合物容易做什么,并且很难让看似最简单的事件发生.
<polymer-element name="field" attributes=" type name value">
<template>
<label>{{name}}
<input type={{type}} name={{name}} value={{value}}>
</label>
</template>
<script>
Polymer('field', {
onblur: function () {
console.log('blurred');
}
})
</script>
</polymer-element>
Run Code Online (Sandbox Code Playgroud)
我已经创建了这个元素,并希望在模糊中做一些事情,有人知道我错过了什么或者我应该在文档中找到什么?
name="field"不匹配Polymer('profile-field',但我认为这只是某种错字.
blur事件不会冒泡,因此输入模糊不会导致blur主机元素上的事件.
最好不要覆盖on<event>函数,最好使用Polymer事件绑定.
我不确定这是否真的是你所追求的,但这里是一个听取输入本身模糊的例子.
<polymer-element name="profile-field" attributes="type name value">
<template>
<label>{{name}}
<input on-blur="{{inputBlur}}" type="{{type}}" name="{{name}}" value="{{value}}">
</label>
</template>
<script>
Polymer('profile-field', {
inputBlur: function () {
console.log('input blurred');
}
})
</script>
</polymer-element>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4796 次 |
| 最近记录: |