我创建了一个打字原稿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) 我在我的项目中使用 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)