WebStorm创建Vite(Vue模版)项目后:
在main.ts中:
import {createApp} from 'vue'
// @ts-ignore
import {createStore} from 'vuex'
import './style.css'
// @ts-ignore
import App from './App.vue'
// @ts-ignore
const store = createStore({
state() {
return {
count: 0
}
},
mutations: {
// @ts-ignore
increment(state) {
state.count++
}
}
})
let app = createApp(App);
app.mount('#app');
app.use(store)
vuex应该是自带的,没有的话进行安装
https://vuex.vuejs.org/zh/installation.html