我有一个相当大的Vue / Vuitify项目,无法正常工作。我已将该项目简化为一个说明该错误的小程序。我已经尝试了所有我能想到的东西,甚至是我想不到的东西。一点帮助将不胜感激。
这是AppTry.vue
:
<template>
<v-container>
<v-main>
<div>Hello! The value is: {{ value }}</div>
<v-btn
color="#0A368E"
class="mr-4 white--text"
@click="btnClicked"
>
Go
</v-btn>
</v-main>
</v-container>
</template>
<script>
export default {
name: "AppTry",
data() {
return {
value: '',
}
},
methods: {
btnClicked: () => {
this.value = 'qwerty'
}
}
}
</script>
<style scoped>
</style>
程序加载后,单击“开始”按钮,在JS控制台中出现以下错误:
[Vue warn]: Error in v-on handler: "TypeError: Cannot set property 'value' of undefined"
found in
---> <VBtn>
<VMain>
<AppTry> at src/components/AppTry.vue
<VApp>
<App> at src/App.vue
<Root>
vue.runtime.esm.js?2b0e:1888 TypeError: Cannot set property 'value' of undefined
at VueComponent.btnClicked (AppTry.vue?467d:26)
at invokeWithErrorHandling (vue.runtime.esm.js?2b0e:1854)
at VueComponent.invoker (vue.runtime.esm.js?2b0e:2179)
at invokeWithErrorHandling (vue.runtime.esm.js?2b0e:1854)
at VueComponent.Vue.$emit (vue.runtime.esm.js?2b0e:3888)
at VueComponent.click (vuetify.js?ce5b:2484)
at invokeWithErrorHandling (vue.runtime.esm.js?2b0e:1854)
at HTMLButtonElement.invoker (vue.runtime.esm.js?2b0e:2179)
at HTMLButtonElement.original._wrapper (vue.runtime.esm.js?2b0e:6917)
btnClicked(){
this.value = 'qwerty'
}
就像这样,箭头函数没有它自己的这个。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句