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元素構建自定義事件''它會調用自定義事件'構建'事件處理程序 –