相关疑难解决方法(0)

属性“XXX”在类型“CombinedVueInstance<Vue, {}, {}, {}, Readonly<Record<never, any>>>”上不存在

我创建了一个打字原稿VUE组成部分,我在得到这个错误data(),并在methods()

Property 'xxx' does not exist on type 'CombinedVueInstance<Vue, {},
{}, {}, Readonly<Record<never, any>>>'.
Run Code Online (Sandbox Code Playgroud)

例如:

33:18 Property 'open' does not exist on type 'CombinedVueInstance<Vue, {}, {}, {}, Readonly<Record<never, any>>>'.
    31 |         methods: {
    32 |             toggle: function () {
  > 33 |                 this.open = !this.open
       |                  ^
    34 |                 if (this.open) {
    35 |                     // Add click listener to whole page to close dropdown
    36 |                     document.addEventListener('click', this.close)
Run Code Online (Sandbox Code Playgroud)

此错误还显示任何时间this.close()被使用。

这是组件:

<script lang='ts'>
    import Vue …
Run Code Online (Sandbox Code Playgroud)

javascript typescript vue.js vuejs2

19
推荐指数
9
解决办法
2万
查看次数

Vue.js 3 类型“CreateComponentPublicInstance”上不存在属性“$store”

我在我的项目中使用 vue.js 3、typescript 和 vuex 4。this.$store但是在我的.vue文件上使用时出现此错误

Property '$store' does not exist on type 'CreateComponentPublicInstance<{}, {}, { exchanges: Exchange[]; isValidNodeUrl: boolean; isValidSelectedNetworks: boolean; web3: "" | Web3; privateKey: string; jsonKeystore: string; jsonKeystorePassword: string; ... 24 more ...; botIsRunning: boolean; }, ... 14 more ..., {}>'
Run Code Online (Sandbox Code Playgroud)

vuex.d.ts我根据此文档 添加了内容,但仍然遇到相同的错误https://next.vuex.vuejs.org/guide/typescript-support.html

import { Store } from "vuex";
import { ComponentCustomProperties } from "vue";

import { State } from "@/interfaces/bot";

declare module "@vue/runtime-core" {
  // Declare your own store …
Run Code Online (Sandbox Code Playgroud)

typescript vue.js vuex

6
推荐指数
1
解决办法
3260
查看次数

标签 统计

typescript ×2

vue.js ×2

javascript ×1

vuejs2 ×1

vuex ×1