帶封裝的配置路由
在min.js中引入路由??import router from './router'
在conponents文件夾內(nèi)建一個(gè)文件inden.js用來封裝路徑:
書寫標(biāo)準(zhǔn):export const index=()=>import('./index.vue')
然后,再見一個(gè)文件夾-router ---建一個(gè)文件---index.js配置路由:
import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
import { index,education,research } from '@/components'
export default new VueRouter({
? ? routes: [
? ? ? ? {
? ? ? ? ? ? path: '/',
? ? ? ? ? ? component: index
? ? ? ? },
? ? ? ? {
? ? ? ? ? ? path: '/education',
? ? ? ? ? ? component: education
? ? ? ? },
? ? ? ? {
? ? ? ? ? ? path: '/research',
? ? ? ? ? ? component: research
? ? ? ? }
? ? ]
})
要在min.js中寫router
在要跳轉(zhuǎn)的字前面寫:<router-link tag="li" to="/education">教育教學(xué)</router-link>
最后要在app.vue中需要跳轉(zhuǎn)的地方寫:<router-view></router-view>