Skip to content

vue-cli3.x 在使用路由按需加载以及嵌套路由时,进入子路由时报错 #3027

@H-Sven

Description

@H-Sven

Version

3.2.1

When vue-cli3.x uses routing loading on demand and nested routing, it makes errors when it enters subrouting

Reproduction link

https://segmentfault.com/q/1010000017171899?_ea=5193336

Node and OS info

8.12.0

Steps to reproduce

const router = new Router({
  routes: [
    {path: '*',name: '',redirect: '/index'},
    // 账户资料模块
    {
      path: '/',
      name: '首页',
      component:() =>import(/* webpackChunkName: "0" */ "./views/Home.vue"),
      children: [
        {path: 'index',name: '页面首页',component: () =>import(/* webpackChunkName: "1" */ "./views/Index.vue")},
        {path: 'order',name: '订单记录',component: () =>import(/* webpackChunkName: "2" */ "./views/Order.vue")},
        {
          path: 'assets',
          name: '资产',
          component: () =>import(/* webpackChunkName: "3" */ "./views/assets/Assets.vue"),
          children:[
            {path: 'index',name: '资产首页',component: () =>import(/* webpackChunkName: "4" */ "./views/assets/Index.vue")},
            {path: 'withdrawal',name: '提现',component: () =>import(/* webpackChunkName: "5" */ "./views/assets/Withdrawal.vue")},
            {path: 'record',name: '提现记录',component: () =>import(/* webpackChunkName: "6" */ "./views/assets/Record.vue")},
            {path: 'details',name: '账单明细',component: () =>import(/* webpackChunkName: "7" */ "./views/assets/Details.vue")},
            {path: 'recordDetails',name: '提现详情',component: () =>import(/* webpackChunkName: "8" */ "./views/assets/RecordDetails.vue")},
          ]
        },
        {
          path: 'account',
          name: '账户中心',
          component: () =>import(/* webpackChunkName: "9" */ "./views/account/Account.vue"),
          children:[
            {path: 'index',name: '账户中心首页',component: () =>import(/* webpackChunkName: "10" */ "./views/account/Index.vue")},
          ]
        },
      ]
    },
  ]
});

snipaste_2018-11-28_14-10-25
111

1

0,1,2,3,4.js all entered the routing normally. Then when I entered the same sub-routing 5 as 4, I loaded 5.js and a vendors105.js and 10~5.js at the same time. But the corresponding routing of 5 also entered normally. Then I visited the same 6.js corresponding routing as 5 and got the error mentioned above.

Why do you load JS like vendors105.js and 105.js?

What is expected?

正常进入子路由

What is actually happening?

无法进入子路由

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions