【发布时间】:2021-11-10 07:51:18
【问题描述】:
代码:
export default {
data() {
return {
nameCity: '',
}
},
methods: {
findCity(event){
event.preventDefault()
findCityCust().then(function(response) {
console.log(response)
this.nameCity = response;
})
},
},
}
这里 - this.nameCity = response; - 抛出一个错误 Uncaught (in promise) TypeError: Cannot read properties of undefined
如何在 Vue 3 中处理来自异步方法的字段?
【问题讨论】:
标签: javascript vue.js vuejs3