this.$router.push(location)不行的原因之一

 goSearch(event){

        // this.$router.push('/search')

        let element = event.target

        let {categoryname,category1id,category2id,category3id} = element.dataset

        // 如果标签上有categoryname一定是a标签

        if(categoryname){

            //整理路由跳转的参数

            let loction = {name:'search'};

            let query = {categoryName:categoryname}

            // 一级分类二级分类三级分类的a标签

            if(category1id){

             query.category1Id= category1id

            }else if(category2id){

             query.category2Id= category2id

            }else {

             query.category3Id= category3id

            }

            // 判断路由跳转的时候,带有params参数。捎带传过去

            if (this.$route.params) {

             loction.params = this.$route.params

                // 整理完参数(对象赋值)

            loction.query = query

            // 路由跳转

            this.$router.push(loction)

            }

        }

    },

  

 methods: {

    AddSearch(){

        // 路由传参

       if (this.$route.query) {

        let loction =  { name:"search",params:{keyword:this.password || undefined} }

         loction.query = this.$route.query

         this.$router.push(loction)

       }

    }

  }

解决 路由配置name

  {

            path: '/home',

            name:'home',

            component: Home,

            // 路由元信息 作为footer显示隐藏的判段条件频繁操作用v-show

            meta: { requiresAuth: true }

        }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值