在onshow()中使用setdata不生效呢?

发布于 8 年前作者 haolei14837 次浏览最后编辑 8 年前来自 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 回复
nmo
nmo1 楼6 年前

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

yan47
yan472 楼6 年前

onShow: function () {

var _this=this;

_this.setData({})//试试

}

nsu
nsu3 楼6 年前

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

xiulandu
xiulandu4 楼6 年前

看看数据是否是正常的?

ghao
ghao5 楼6 年前

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

kxue
kxue6 楼6 年前

页面是不是有多个onShow啊

ping70
ping707 楼6 年前

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

baichao
baichao8 楼6 年前
WXOPEN Club 内容图片 WXOPEN Club 内容图片 WXOPEN Club 内容图片