vue3中在".vue"文件中使用使用"$store"报警告问题
2022/9/17 23:18:44
本文主要是介绍vue3中在".vue"文件中使用使用"$store"报警告问题,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
问题
使用最新版的vuex后,然后vue3在template模版中使用出现红色警告,但是编译无异常
效果图
解决办法:
在shims-vue.d.ts
文件中新增下面的声明
// shims-vue.d.ts import { Store } from '@/store' declare module '@vue/runtime-core' { interface ComponentCustomProperties { $store: Store } }
资料链接
- stack overflow:https://stackoverflow.com/questions/64412243/vue-js-3-and-typescript-property-store-does-not-exist-on-type-componentpub/68917028
- vuex 官网:https://vuex.vuejs.org/guide/typescript-support.html#typing-store-property-in-vue-component
这篇关于vue3中在".vue"文件中使用使用"$store"报警告问题的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-03-30[OIDC in Action] 2. 基于OIDC(OpenID Connect)的SSO(纯JS客户端)
- 2024-03-29terraform jsonencode
- 2024-03-13vuex-persist
- 2024-03-11icons for vue
- 2024-03-07breadcrumbs react js
- 2024-03-06react login page example
- 2024-03-06react router uselocation
- 2024-03-04postgres jsonb_set
- 2024-03-01react native uuid
- 2024-02-29vuejs sidebar