params路由

  {
            //params占位 用来接受路由传递的参数
            path: '/search/:keyWord',
            name: 'search',
            component: () => import('@/views/Search'),
            meta: { show: true }
        },

对象写法

 1router.push(`/search/${keyWord.value}`)
2
            router.push({
                name: 'search',
                params: { keyWord: keyWord.value }
            })

接受参数

  {{ route.params.keyWord }}

query

{
 path: '/search',
            name: 'search',
            component: () => import('@/views/Search'),
            meta: { show: true }
}
 1 router.push(`/search/?k=${keyWord.value}`)
            2 router.push({
                name: 'search',
                query: { k: keyWord.value }
            })

接受参数

{{ route.query.k }}

Logo

前往低代码交流专区

更多推荐