在onshow()中使用setdata不生效呢?
发布于 6 年前 作者 haolei 14672 次浏览 来自 官方Issues

onShow: function () {

let pages = getCurrentPages(),

currPage = pages[pages.length - 1];

console.log(currPage.data)

if(currPage.data.uid !== undefined){

console.log(‘uid’)

this.setData({

clickNumber: 0

});

console.log(this.data.clickNumber)

} else if (currPage.data.type === “2”){

var shsh = new Array();

shsh[‘name’] = currPage.data.name

shsh[‘mobile’] = currPage.data.mobile

shsh[‘address’] = currPage.data.address

shsh[‘city’] = currPage.data.city

shsh[‘county’] = currPage.data.county

shsh[‘province’] = currPage.data.province

console.log(‘收货’)

console.log(currPage.data.mobile)

this.setData({

clickNumber: 0,

shsh: shsh

})

console.log(shsh);

}else{

console.log(‘其他’)

this.setData({

clickNumber: 0,

})

}

},

8 回复

看看有没有报错,抛出异常之类的

onShow: function () {

var _this=this;

_this.setData({})//试试

}

你 吧shsh变成一个对象试一下 不要用数组

看看数据是否是正常的?

console.log(CurrentPage.data) 能打印出来吗

页面是不是有多个onShow啊

怎么个不生效法?没发现你说的问题

回到顶部