Egg Vue SSR 服务端渲染数据请求与asyncData(2)

// 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') } ] }); }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/3d107766e56a7e5777b837afa3cc62d7.html