1. 字符串路由传参
route下的index.js
{
path: '/search/:keyword',
name: 'Search',
component: () => import('../views/Search/index.vue'),
meta:{
show:true
}
components下的header.vue
this.$router.push(
"/search/" + this.keyword + "?k=" + this.keyword.toUpperCase()
);
![在这里插入图片描述](https://img-blog.csdnimg.cn/01d7ddfd0c19426fb75c784cfacf5d74.png)
2. 模板字符串路由传参
route下的index.js同上
components下的header.vue
methods: {
goSearch() {
this.$router.push(`/search/${
this.keyword}?k=${
this.keyword.toUpperCase()}`)
},
},
![在这里插入图片描述](https://img-blog.csdnimg.cn/cd826f2da7a240d690043516ebe37a7c.png)
3. 对象路由传参
route下的index.js同上
components下的header.vue
methods: {
goSearch() {
this.$router.push