s***@qq.com
s***@qq.com
  • 发布:2022-08-09 00:30
  • 更新:2022-08-09 18:46
  • 阅读:739

为啥onload中的this是undefined呢

分类:uni-app

为啥onload中的this是undefined呢
export default {
data() {
return {
aaaa: 'aaaa'
}
},
onLoad: () => {
console.log(this) // undefined
console.log(this.aaaa) // undefined
},
}

2022-08-09 00:30 负责人:无 分享
已邀请:
s***@qq.com

s***@qq.com (作者)

蛋疼换成onLoad = function(){} 就正常了
建议修复

  • 1***@qq.com

    人家这不是bug,是你自己语法写错了

    2022-08-09 08:51

CODE_XU

CODE_XU

语法没有问题,建议了解一下箭头函数与普通函数有哪些区别

该问题目前已经被锁定, 无法添加新回复