1、给router-view取个名字:

<router-view name = "view_home"/>

2、在index.js中这样写

export default new Router({
  routes: [
    {
      path: '/',
      redirect: 'HomePage'
    },
    {
      path: '/HomePage',
      name: 'HomePage',
      components: {
        view_home: HomePage
      }
    }
  ],
  mode:'history'
})

to到对应path的时候在components属性中按name属性确定要更新的router-view

Logo

前往低代码交流专区

更多推荐