“ TypeError:无法读取未定义的属性”

蒂莫西·克诺兹(Timothy Knautz)

我有一个相当大的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)
刘li
   btnClicked(){
      this.value = 'qwerty'
    }

就像这样,箭头函数没有它自己的这个。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

TypeError:无法读取未定义的属性“ then”

“ TypeError:无法读取未定义的属性'then'

TypeError:无法读取未定义的属性“未定义”

如何修复'TypeError:无法读取未定义的属性'then'TypeError:无法读取未定义的属性'then'...'

TypeError:无法读取未定义的属性(读取“pageNumber”)

React TypeError:无法读取未定义的属性(读取“状态”)

“TypeError:无法读取未定义的属性(读取'id')”

TypeError:无法读取未定义的属性(读取“有”)

ReactJS TypeError:无法读取未定义的属性(读取“地图”)

反应 - 错误:TypeError:无法读取未定义的属性(读取“then”)

TypeError:无法读取未定义的属性(读取“等于”)

React - TypeError:无法读取未定义的属性(读取“参数”)?

“TypeError:无法读取未定义的属性(读取'hasOwnProperty')”错误

TypeError:无法读取未定义的属性“数据”-但已定义

刷卡器:TypeError:无法读取未定义的属性“ push”或TypeError:classNames未定义

UnhandledPromiseRejectionWarning: TypeError: 无法读取未定义的属性“body”

Formik-TypeError:无法读取未定义的属性'type'?

TypeError:无法读取未定义的属性“编译”

未捕获的TypeError:无法读取未定义的属性“值”

TypeError:无法读取未定义的属性“ map”

未捕获的TypeError:无法读取未定义的属性“ toLowerCase”

未捕获的TypeError:无法读取未定义的属性“ close”

Uncaught TypeError:无法读取未定义的属性“轴”

TypeScript:TypeError:无法读取未定义的属性“ push”

TypeError:无法读取未定义的属性“条件”

TypeError:无法读取未定义的属性“管道”

TypeError:无法读取未定义的属性“协议”

反应TypeError:无法读取未定义的属性“替换”

TypeError:无法读取未定义的属性“ directoryExists”