Vue3.x+ts 使用vuex
转载配置全局属性-vue3配置全局axioslink.vue3+ts 全局挂载以及声明写法link.官方配置link在.vue文件中声明lang=’'ts"可能引起报错此时需要在用到vuex的ts文件里import { createStore,Store } from 'vuex'import {ComponentCustomProperties} from 'vue'declare module
·
转载
配置全局属性-vue3配置全局axios
link.
vue3+ts 全局挂载以及声明写法
link.
官方配置
link
在.vue文件中声明
lang=’'ts"可能引起报错
此时需要在用到vuex的ts文件里
import { createStore,Store } from 'vuex'
import {ComponentCustomProperties} from 'vue'
declare module '@vue/runtime-core'{
interface State{
count: number,
todos:Array<object>
}
//provide typings for `this.$store`
interface ComponentCustomProperties{
$store:Store<State>
}
}
export default createStore({
state: {
count:0,
todos: [
{ id: 1, text: '...', done: true },
{ id: 2, text: '...', done: false }
]
},
getters:{
},
mutations: {
},
actions: {
},
modules: {
}
})
多加这么一段定义
其中interface State需要根据自己保存的数据定义
更多推荐
已为社区贡献1条内容
所有评论(0)