cordova在使用jqmobile中出现的问题(使用$(window).on与window.addEventListener)

因为使用jq mobile需要导入jquery,所以在创建监听函数时习惯使用jq,但是会导致一些问题。

//$(window).on("batterystatus",onBatteryStatus); 冲突,此时传递的info为x.event,原因未知

window.addEventListener("batterystatus",onBatteryStatus,false)正常


function onBatteryStatus(info) {
console.log(info)
   alert("BATTERY STATUS:  Level: " + info.level + " isPlugged: " + info.isPlugged);

}


所以最好还是使用原生写,毕竟cordova是一个独立的框架

猜你喜欢

转载自blog.csdn.net/qq_32524473/article/details/80624913