1
目前我使用这样的代码我如何从HTML元素中引发自定义事件?
// Create the event.
var event = document.createEvent('Event');
// Define that the event name is 'swiping'.
event.initEvent('swiping', true, true);
// Listen for the event.
elem.addEventListener('swiping', function (e) {
// e.target matches elem
}, false);
// target can be any Element or other EventTarget.
elem.dispatchEvent(event);
处理单元刷卡
我怎么火从HTML元素此活动? (如<div on-swiping="function-name"></div>
OR PolymerJS自定义元素的事件on-click
,on-tap
等)
我期待'<按钮上建造= “功能名”>按钮'ü可以看到聚合物做自定义事件以这种方式 –
怎么办你意思是?您是否需要使用'聚合物'而不是常规的'javascript'触发自定义事件? –
我想调用像这样的HTML元素构建自定义事件''它会调用自定义事件'构建'事件处理程序 –