setData()无法赋值,为什么用wx:for页面不渲染?

小程序 文章 2022-01-27 16:00 775 0 全屏看文

AI助手支持GPT4.0

setData()无法赋值,为什么用wx:for页面不渲染?setData() cannot be assigned, why is the page not rendered with wx:for?

setData()无法赋值,为什么用wx:for页面不渲染?

调用函数获取到的数组,通过setData赋值,页面上通过wx:for渲染。但是查到的数据未渲染。

初始化赋值:

控制台能打印全部的数据,但是也很奇怪。

但是页面上只能显示初始赋值的数据,没有调用方法获得的新数据

部分代码

The array obtained by calling the function is assigned by SetData, and the page is rendered by Wx: for. However, the data found was not rendered. Initialization assignment: the console can print all the data, but it's also strange. However, only the data of the initial assignment can be displayed on the page, and there is no code for the new data obtained by calling the method

回答:

brave:

异步。。。

dreamhunter:

需要用setData https://developers.weixin.qq.com/miniprogram/deveference/api/Page.html#%E7%BB%84%E4%BB%B6%E4%BA%8B%E4%BB%B6%E5%A4%84%E7%90%86%E5%87%BD%E6%95%B0

  1. 直接修改 this.data 而不调用 this.setData 是无法改变页面的状态的,还会造成数据不一致


拾忆:

JS异步问题

-EOF-

AI助手支持GPT4.0


国内超级便宜服务器

摸鱼人热门新闻聚合

钻级赞助商 我要加入

开发者在线工具

第三方支付技术请加QQ群

相关文章
申请解除微信访问拦截网站?www.o588.cn
onShareAppMessage能否支持点击分享内容跳到另外一个小程序?
调试版可以调试,体验版为什么不能正常访问?
请问这个配置页面在哪里
微信红包封面发放有下限吗?最低发放多少个之类
随便看看
小程序测试号解绑之后,扫一扫小程序登录又回来了 2101
微信公众号openid? 2347
微信开放平台跟公众平台有什么区别? 3608
怎么添加小程序支付功能? 4516
教育科技公司申请微信支付被拒绝? 4799
微信公众号免300认证教程 5892
小程序已经上线,作为管理员无法在小程序数据助手查看数据? 5299
小程序广告组件通过审核,但是小程序内没有显示广告? 5067
企业微信通讯录账号被管理员误/恶意删除,怎么办? 9568
问题? 9048