TypeError: Cannot read property ‘username‘ of undefined

TypeError: Cannot read property ‘username’ of undefined

最近在uni-app开发安卓app的项目中用到onLoad()生命周期中,需要改变username的值,但是频频报错:TypeError: Cannot read property ‘username’ of undefined

后面才发现是箭头函数this的指向问题,一开始生命周期使用箭头函数封装了:
TypeError: Cannot read property ‘username‘ of undefined
导致this一直指向undefined,这可能是因为箭头函数对this的指向严格限制,后面还是改回来,就可以了;

TypeError: Cannot read property ‘username‘ of undefined