72、Vue 常用技术

1、路由route

$route属性和$router  路由传递参数 如果是params参数 需要路由占位

        //第一种写法
        //this.$router.push('/search/'+this.keyword+'?k='+this.keyword.toUpperCase());
        //第二种写法 模板字符串
        //this.$router.push(`/search/${this.keyword}?k=${this.keyword.toUpperCase()}`);
        //第三种写法
        let location = {name: "search", params: {keyword: this.keyword || undefined}};
        if(this.$route.query) {
          location.query = this.$route.query;
        }
        this.$router.push(location);

 

posted @ 2022-03-18 19:19  shunnWcs  阅读(27)  评论(0)    收藏  举报