mui事件绑定
一、普通方法:使用addEventListener()
1 document.getElementById("alertBtn").addEventListener('tap', function() { 2 alert('dosomething'); });
二、使用.on
mui('#history-title').on('tap', 'p', function(){
mui.confirm('是否要删除全部搜索记录?','提示',['是','否'],(e)=>{
if (e.index === 0){
window.localStorage.removeItem('historySearch')
fGetStorage()
mui.toast('清除成功',{ duration:'short', type:'div' })
}
})
})
1、其中mui('#history-title')绑定的是需要绑定事件的父元素
2、on('tap', 'p', function(){})对应的是,event, selector, handler(即callback)

浙公网安备 33010602011771号