【Vue3】之vuex的安装与配置

安装

yarn add vuex@4.*
或
npm install -save vuex@4.*

创建

新建store.js
store.js

import {
    
     createStore } from 'vuex'

export default createStore({
    
    
    state: {
    
    
    },
    mutations: {
    
    
    },
    actions: {
    
    
    },
    modules: {
    
    
    }
})

引入

main.js

import {
    
     createApp } from 'vue'
import App from './App.vue'
import './index.css'
import store from './store'

const app = createApp(App)
app.use(store)
app.mount('#app')

猜你喜欢

转载自blog.csdn.net/sky529063865/article/details/117950657