微信小程序:setData报错TypeError: Cannot read property ‘setData‘ of undefined

问题的原因:

无法找到setData这个定义,因为setData中是onLoad函数中的方法中的子节点,

无法使用this

解决办法:

这个时候需要在方法的开始部分定义var that = this,然后用that.setData来重置,这样就解决了这个问题了。

如下图:

你可能感兴趣的:(微信小程序:setData报错TypeError: Cannot read property ‘setData‘ of undefined)