收藏
回答

setData为什么不能赋值?

如题,

onLoad: function (options) {

    var that = this;

    

    // 接收参数

    var tab = 0;

    this.setData({

      tab : options.currentTab

    });

    

    console.log('currentTab:' + options.currentTab);

    console.log('tab:' + tab);

  }


打印结果如下:



tab应该也是1,

var tab = 0;换成tab: 0放在Page的data里会报错,如下:



回答关注问题邀请回答
收藏

1 个回答

  • 小程序运营专员 - cunjin
    小程序运营专员 - cunjin
    2018-05-18

    麻烦给个相关的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html),我们定位下问题

    2018-05-18
    有用
    回复
登录 后发表内容