Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘$emit‘) at eval
this指向的对象取决与函数调用的上下文,在箭头函数中,this的值有最外层(最接近的非箭头函数)作用域决定。使用 this.$modal.confirm().then() 方法做页面跳转时报错。方法一:使用箭头函数或在‘then’方法中绑定‘this’方法二:使用‘bind’方法显式绑定‘this'方法三:将’this‘存储在一个变量中。
原创
2024-06-24 11:15:36 ·
411 阅读 ·
0 评论