picker选择确定后,this.setData成功,页面不刷新?

小程序 文章 2022-01-07 09:40 1051 0 全屏看文

AI助手支持GPT4.0

picker选择确定后,this.setData成功,页面不刷新?After the picker is selected, this.setData is successful, but the page does not refresh?

picker选择确定后,this.setData成功,页面不刷新?

wxml部分代码:

<picker bindchange="bindPickerChange" value="{{index}}" range="{{userCouponList}}" range-key="name">            <view>{{index}}</view>            <view class="picker">              当前选择:{{userCouponList[index].name}}            </view></picker>

js部分代码:

bindPickerChange: function(e{    console.log('picker发送选择改变,携带值为', e.detail.value)    this.setData({      index: e.detail.value    })    console.log(this.data.index)},


index初始值为0,选择第二个选项以后,index被更新成1,但是页面不会刷新,还是原来的值。

页面如图

-------------------------------------

控制台输出图

可以看到this.data.index更新成功了,页面不会刷新。picker的js复制的官方代码,使用官方示例是可以成功刷新页面的,没搞明白,求解,整了几个小时试了各种方法都没用,已经裂开,求大佬解答

Wxml part code: < picker bindchange = "bindpickerchange" value = "{index}" range = "{usercouponlist}" range key = "name" > < View > {index} < / View > < view class = "picker" > current selection: {{usercouponlist [index]. Name} }< / View > < / picker > JS part of code: bindpickerchange: function (E) {console.log ('picker sends selection change, carrying value ', e.detail. Value) this.setdata ({index: e.detail. Value}) console Log (this. Data. Index)}, the initial value of index is 0. After selecting the second option, the index will be updated to 1, but the page will not be refreshed, but the original value will still be used. The page is as shown in the figure ---------------------------------------- this can be seen in the console output diagram data. The index update is successful. The page will not be refreshed. The official code copied by picker's JS can successfully refresh the page using the official example. I didn't understand it and solved it. I tried all kinds of methods for several hours, but it's useless. It's cracked. Ask the boss for an answer

回答:

15:

你试试把 e.detail.value 这里写死的话有改变吗

this.setData({  index1})


destiny:

检查appdata面板

brave:

你好这边测试正常,提供下可以复现问题的代码片段 https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

微喵网络:

检查appdata面板

-EOF-

AI助手支持GPT4.0