在onload函数里接收传过来的参数options
this.setData({a:options})
console.log(a)
这里的a是undefined,为什么呢,请问怎么解决
为什么setData赋值后打印是undefined呢?Why is printing undefined after setData assignment?
为什么setData赋值后打印是undefined呢?在onload函数里接收传过来的参数options
this.setData({a:options})
console.log(a)
这里的a是undefined,为什么呢,请问怎么解决
Receive the passed parameter options this in the onload function setData({a:options}) console. Log (a) here a is undefined. Why? How to solve it
回答:
因为a没有定义啊 应该是this.data.a
console.log(this.data.a)
onLoad(options) { this.setData({ a: options }, () => { console.log(this.data.a) })}