收藏
回答

wx:for 动态绑定Page.data值

问题模块
API和组件


wx:for不能动态绑定Page.data的值吗?比如


Page.data({

   data_index:[0,1,2],

   page0:{},

   page1:{}

})


<view wx:for="{{data_index}}">


<view wx:for="{{"page"+index}}">

view>




最后一次编辑于  2017-09-25  (未经腾讯允许,不得转载)
邀请回答
复制链接收藏关注问题回答

2 个回答

  • yaoxin
    yaoxin
    2017-09-25

    不支持!

    2017-09-25
    赞同
    回复
  • 锦卓
    锦卓
    2017-11-21

    想到了一个变通的方法

    getUserCouponCodeList:function(e){

        var that=this;

        var status = e? e.currentTarget.dataset.status:0;

        var page=this.data["page"+status] || 0;

        var changeData = {};

        changeData["status"] = status;

        app.request({

            url: 'Coupon/getUserCouponCodeList',

            data: {

            status: status,

            page:page+1

            },

            success: function (res) {

                if (res.data.status == 1) {

                    var couponCodeListStatus = that.data["couponCodeList"+status] || [];

                    var result = res.data.data || [];

                    couponCodeListStatus = couponCodeListStatus.concat(result);

                    changeData["couponCodeList" + status] = couponCodeListStatus;

                    changeData["couponCodeList"] = couponCodeListStatus;

                    changeData["page"+status] = page+1;

                    that.setData(changeData);

                }

            }

        })

    }


    2017-11-21
    赞同
    回复