import Vue from 'vue'; import Vuex from 'vuex'; Vue.use(Vuex); import home from "./home" import search from "./search" const store = new Vuex.Store({ modules : { home, search } }); export default store;
import Vue from 'vue' import App from './App.vue' import router from "@/router" import store from './store'; // 引入我们前面导出的store对象 import TypeNav from "@/pages/Home/TypeNav" import {categoryList} from "@/api" Vue.component(TypeNav.name,TypeNav) categoryList() Vue.config.productionTip = false let a =1; new Vue({ render: h => h(App), router, store, // 把store对象添加到vue实例上 }).$mount('#app')
const state ={} const mutations ={} const actions ={} const getters ={} export default{ state, mutations, actions, getters }
标签:Vue,const,TypeNav,模块化,vue,import,vuex,store From: https://www.cnblogs.com/sgj191024/p/17599431.html