简体   繁体   English

Vue Router我如何在根页面上提供查询参数

[英]Vue router how can i give query params on root page

export default new Router({
  routes: [
    {
      path: '/:userId',
      name: 'top',
      component: Top
    }
  ]
})

I cannot give a query param like this. 我不能给这样的查询参数。

Is it impossible to give param to root view? 将参数赋予根视图是不可能的吗?

export default new Router({
      routes: [
        {
          path: '/top/:userId',
          name: 'top',
          component: Top
        }
      ]
    })

I know this is possible , but I want to give param to root page. 我知道这是可能的,但是我想给根页面添加参数。

You can try : 你可以试试 :

export default new Router({
  routes: [
    {
      path: '/',
      component: Root,
      children: [
      {
        path: ':userId',
        name: 'top',
        component: Top
      }
    }
  ]
})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM