mui手机APP开发,发现用mui.post 和vue.js 引用第二次,数据无法读取,就是只能显示一个详情,或是相关阅读
1,内容页取详情数据和相关阅读数据
//内容详情start
var param = {
url:'/news/v_view',
info:{
id:strs[0]
}
}
var obj = {};
app.getServerDataNew(param['url'],param['info'],function(result){
if(result['code']==200){
app.newVue('article-main',result.data);//
document.getElementById('page-load').style.display="none";
document.getElementById('article-main').style.display="block";
}
});
//内容详情end
//相关阅读start
var param2 = {
url:'/news/v_list',
info:{
type_id:strs[1],
epage:5
}
}
var obj2 = {};
app.getServerDataNew(param2['url'],param2['info'],function(result){
if(result['code']==200){
console.log(2222);//
// console.log(JSON.stringify(result.data.items));
app.newVue('relevant-main',result.data);
document.getElementById('relevant-main').style.display="block";
console.log(3333);
}
});
//相关阅读end
2,vue设置代码
owner.newVue = function(ele, data) {
data = data ? data : [];
var objs = new Vue({
el: '#' + ele,
data: {
data: data
}
});
return objs
}
3,mui.post 设置代码
//新的获取数据
owner.getServerDataNew = function(url, info, callback) {
callback = callback || mui.noop;
info = info || {};
info.platform = platform;
info.add_ip = localStorage.getItem('add_ip');
if (typeof(webUrl) != 'undefined') {
url = webUrl + url
}
mui.post(url, info, function(data) {
return callback(data)
}, 'json');
};
0 个回复