路由传参问题说明

130 阅读1分钟

说一下Vue路由传参问题

1.路由传参

路由传参主要有三种方式 一种是字符串形式传参,一种是模块字符串形式传参,第三种是对象写法(常用) 注:对象传参,必须给路由起一个名字,不能传路径,否则页面跳转会出现问题。

第一种:eg: this.$router.push("/search/" + this.keyword+"?k="+this.keyword.toUpperCase());

第二种:eg: this.router.push(/search/router.push(`/search/{this.keyword}?k=${this.keyword.toUpperCase()}`);

第三种:eg: this.$router.push({name:"search",params:{keyword:this.keyword},query:{k:this.keyword.toUpperCase()}})