Почему при перезагрузке приложения vue динамические параметры router-vue удаляются? - PullRequest
0 голосов
/ 16 мая 2019

Если я перехожу к действительному маршруту (пример: http://example.com/this-route), страница загружается, однако при обновлении браузер перенаправляется в корневой каталог (пример: http://example.com/). Почему это происходит?

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.html [L]
</IfModule>

router.js:

const router = new Router({
  mode: 'history',
  base: '/',
  routes: [{
    path: '/',
    component: ParentComponent,
    children: [{
      // her the route has no problems with reload
        path: '',
        name: 'home',
        props: true,
        component: ChildComponent,
      },
      {
       // her the route has no problems with reload
        path: 'not-found',
        name: 'notfound',
      },
      {
       // the problem comes from the dynamic parameters
        path: ':params',
        name: 'page',
        props: true,
        component: ChildComponent,
      }
    ]
  }]
})
export default router
...