Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
252 views
in Technique[技术] by (71.8m points)

vue-router不显示

router-view空白,同样的结构在我的其他项目里都没问题,不知道这里为什么不能显示。

目录结构如下
TIM截图20200710102417.png

main.js

import Vue from 'vue'
import App from './home.vue'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import '../../assets/reset.css'
import router from './router';

Vue.config.productionTip = false
Vue.use(ElementUI) //element

new Vue({
  router,
  render: h => h(App)
}).$mount('#home')

`
router.js

import Vue from 'vue'
import Router from 'vue-router'
import HelpManual from './helpManual.vue'

Vue.use(Router)

const router = new Router({
    routes: [{
        path: '/',
        name: 'helpManual',
        component: HelpManual,
    }, {
        path: '/about',
        name: 'about',
        component: () => import('./views/About.vue')
    }]
})
router.beforeEach((to, from, next) => {

})

router.afterEach(route => {

})

export default router

`
home.vue
`

<template>
  <div id="home">
    1111
    <router-view/>
  </div>
</template>
<script>
export default {
  name: "home",
};
</script>
<style lang="scss">
</style>

)7(HMT6H(K8UJG`9UU2V0WS.png


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

已解决,折腾了半天,少了个next()

router.beforeEach((to, from, next) => {
    next()
})

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...