配置vuex

配置vuex,第1张

1.store.js(store文件夹在里面定义)
// 导入vue
import Vue from 'vue'
// 导入vuex
import Vuex from 'vuex'
// 将 Vuex 安装为 Vue 的插件
Vue.use(vuex)
// 创建store对象
const store=new Vuex.Store({
   state:{}
})
// 向外共享 Store 的实例对象
export default store
2.在main.js中导入store实例对象并挂载到 Vue 的实例上
//导入store实例对象
import store from './store/store.js'
//将store挂在到vue实例上
const app=new Vue({
...App,
store
})
app.$mount()

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1322771.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-12
下一篇2022-06-12

发表评论

登录后才能评论

评论列表(0条)

    保存