// index.js 'use strict'; import App from 'framework/app.js'; import index from './index.vue'; import createStore from './store'; import createRouter from './router'; const options = { base: 'https://www.jb51.net/' }; export default new App({ index, options, createStore, createRouter, }).bootstrap();
前端 router / store 定义
// store/index.js 'use strict'; import Vue from 'vue'; import Vuex from 'vuex'; import actions from './actions'; import getters from './getters'; import mutations from './mutations'; Vue.use(Vuex); export default function createStore(initState = {}) { const state = { articleList: [], article: {}, ...initState }; return new Vuex.Store({ state, actions, getters, mutations }); } // router/index.js import Vue from 'vue'; import VueRouter from 'vue-router'; import ListView from './list'; Vue.use(VueRouter); export default function createRouter() { return new VueRouter({ mode: 'history', base: 'https://www.jb51.net/', routes: [ { path: 'https://www.jb51.net/', component: ListView }, { path: '/list', component: ListView }, { path: '/detail/:id', component: () => import('./detail') } ] }); }