html52.com
我爱小程序-开发者交流社区

wx:for遍历数组,如何在数组更新时同时更新for循环?

wxml文件

<scroll-view class="scroll-reminders" scroll-y="true">

    <view

    wx:for="{{notes}}"

    wx:for-item="{{note}}"

    >

        {{note}}

    </view>

js文件

onSubmitEvent: function(e){

  // 得到用户欲添加,此处先保存显示,后续要上传云端

  this.data.notes.push(e.detail.value.newReminders)

  this.setData({

    notes: this.data.notes,

  })

  console.log(this.data.notes)

} 

如果不用wx:for,直接显示的话可以直接更新,但加上wx:for就没办法了,各位大佬有什么解决方法么?

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付