WASubContext.js?t=wechat&s=1659519201563&v=2.20.2:2 Unhandled promise rejection ReferenceError: test_tip is not defined
小程序开发的时候,调用变量出现这个报错,是因为变量的作用域
的问题
// data 变量声明
test_tip: "test",
// 变量使用
console.log(test_tip)
报错
解决办法
使用that关键字来引用变量
let that = this
console.log(that.test_tip)
就可以解决问题