vue路由传参params与query实例 zzzzzT 2022-04-21 170 阅读1分钟 页面路由带参跳转: 1.query传参 (query是拼接在url后面的参数) this.router.push(path:"跳转路径",query:参数名:参数);接收参数:this.router.push({ path: "跳转路径", query: { 参数名: 参数 } }); 接收参数:this.router.push(path:"跳转路径",query:参数名:参数);接收参数:this.route.query.参数名 2.params传参 params传参为空串时传参时加上undefined判断 this.router.push(name:"search",params:keyword:""∣∣undefined,,);接收参数::this.router.push({ name: "search", params: { keyword: "" || undefined, }, }); 接收参数::this.router.push(name:"search",params:keyword:""∣∣undefined,,);接收参数::this.route.params.keyword