无尚荣耀
无尚荣耀
  • 发布:2016-01-22 13:15
  • 更新:2016-01-22 14:31
  • 阅读:1329

事件监听根本无法解除 贴了代码

分类:MUI
mui

function 绑定事件重复的函数(){

var showCityPickerButton = doc.getElementById('showCityPicker3'); $("#showCityPicker3").removeListener;$("#showCityPicker3").off();mui(showCityPickerButton).off();
showCityPickerButton.addEventListener('tap', function(event) {
$("#showCityPicker3").removeListener;$("#showCityPicker3").off();mui(showCityPickerButton).off();
alert("调用几次就弹出几次,说明事件只能绑定不能解除");
}

}

绑定事件重复的函数(); //弹出一次
绑定事件重复的函数(); //弹出二次
绑定事件重复的函数(); ...
绑定事件重复的函数(); ..
绑定事件重复的函数();// 到这里,会连续弹出五次。

2016-01-22 13:15 负责人:无 分享
已邀请:
老王

老王

绑定事件需要写到函数里么, 貌似不需要, 如果写在函数里, 先明确那是你需要的

函数每次执行就相当于绑定一次, 当然重复了

无尚荣耀

无尚荣耀 (作者)

解决了,用了 removeEventListener 可以在每次调用后解除绑定。

绑定事件不是必须写到函数里,但必须要改写mui里的js才能做到,太麻烦了。

该问题目前已经被锁定, 无法添加新回复