今天才发现的一个奇怪问题,从主页面打开一个预加载页面,点击的时候添加自定义事件,进入列表页,列表页监听点击添加的自定义事件刷新数据,在列表页的监听事件函数中写点击事件,会随着主页面进入列表页次数的增加而增加,请问是什么原因。代码大概是下面这样的
//首页代码
(function($) {
var localBusiness_view;
var hotel_searcHotel_view;
$.plusReady(function() {
if (!hotel_searcHotel_view) {
hotel_searcHotel_view = $.preload({
url: 'page/hotel_searcHotel.html',
id: "hotel_searcHotel",
waiting: {
autoShow: false
}
});
}
if (!localBusiness_view) {
localBusiness_view = $.preload({
url: 'page/localBusiness.html',
id: "localBusiness",
waiting: {
autoShow: false
}
});
}
});
$("#list1").on("tap", ".webkitbox", function() {
var dataIt = this.getAttribute("data-item");
if (dataIt == "1") {
var type = this.getAttribute("data-type");
$.fire(localBusiness_view, "localBusiness_view", {
type: type
});
localBusiness_view.show("pop-in");
} else {
$.fire(hotel_searcHotel_view, "hotel_searcHotel_view", {});
hotel_searcHotel_view.show("pop-in");
}
});
})(mui);
//列表页代码
window.addEventListener("localBusiness_view", function(event) {
(function($) {
$('#temp').on('tap', 'li', function(event) {
console.log(">>>>>>>>>>>>>>>");
var loc = this.getAttribute("data-url");
localStorage.setItem("baiduurl", loc);
var baidu = plus.webview.create("localbusinessbaidu.html", "localbusinessbaidu");
baidu.show("pop-in");
});
})(mui);
})
0 个回复