如下代码,列表页打开详情页,使用openwindow打开接收新闻标题、时间、内容,但都显示undefined.
但是当我用数字的形式不用变量传递就可以。如title:data_title[1]
是什么问题导致无法接收使用变量形式的数组参数呢?
var data_title = new Array(),data_date = new Array(),data_content = new Array();
//遍历取回的数据对象,其中data是通过ajax请求回来的json对象
mui.each(data,function(index){
if(index==0){return};
sListOk = sListOk +
'<div class="mui-slider-item">'+
'<a href="show.html" data-id="'+index+'">'+
'<img src="'+domain+data[index].pic01_src+'">'+
'<p class="mui-slider-title">'+data[index].title+'</p>'+
'</a>'+
'</div>';
sarr_img.push(data[index].pic01_src);
sarr_title.push(data[index].title);
slarr.push(index);
data_title.push(data[index].title);
data_date.push(data[index].add_time);
data_content.push(data[index].content);
});
//焦点图点击事件
mui('#slider').on('tap', 'a', function() {
var id = this.getAttribute('href');
var href = this.href;
var data_id = parseInt(this.getAttribute('data-id'))-1;
var webview_style = {
popGesture: "close",
top: '0px',
bottom: '0px'
};
mui.openWindow({
id: id,
url: this.href,
styles: webview_style,
show: {
aniShow: aniShow
},
waiting: {
autoShow: true,
title:'正在加载...'
},
extras:{
title:data_title[data_id],
date:data_date[data_id],
content:data_content[data_id]
}
});
});
//目标页取值
//接收传递来的值
var self=plus.webview.currentWebview();
var aTitle = document.getElementById("aTitle");
var aDate = document.getElementById("aDate");
var aContent = document.getElementById("aContent");
aTitle.innerHTML = self.title;
aDate.innerHTML = self.date;
aContent.innerHTML = self.content;
1 个回复
4***@qq.com
能传的