vue路由传参的三种写法

 methods:{
       
        goSearch(){

             // 1.路由传参字符串形式
            // this.$router.push("/Search/"+this.keyword+"?k="+this.keyword.toUpperCase())

            // 2 模板字符串
            // this.$router.push(`/search/${this.keyword}?k=${this.keyword.toUpperCase()}`)

            //3.对象传参
            this.$router.push({
                name:"search",
                params:{keyword:this.keyword},
                query:{k:this.keyword.toUpperCase()}
            })
        }
    },

 

posted @ 2022-11-26 16:20  小白字太白  阅读(25)  评论(0编辑  收藏  举报