1. 当点击全部分类时需要携带参数,如果点击了全部分类后,还添加了关键词搜索时也需要携带参数,所以此时需要合并参数
//src >>> components >>> Header >>> index.vue
<script>
export default {
name: '',
data(){
return {
keyword:'',
},
methods:{
//搜索按钮的事件处理函数,用于跳转至search路由组件当中
goSearch(){
//如果有query参数也要传过去
if(this.$route.query){
let location = {name:"search",params:{keyword:this.keyword || undefined}}
location.query = this.$route.query
this.$router.push(location)
}
}
}
}
}
</scirpt>