当我使用$ router.push添加新查询以路由Nuxt watchQuery无法正常工作并且asyncData无法获取api并重新安装子组件时。请注意“新查询”,并且默认情况下不存在任何查询。(创建新查询然后存在查询后,每件事都正确,并且watchQuery正常工作。)
example.com/some-param ----> example.com/some-param?brand=x(不能正常使用watchQuery)
example.com/some-param?brand=x ----> example.com/some-param(正确的watchQuery)
change_brand: function () {
const vm = this;
/*** selected_brands = [] is an array defined in data ***/
let q = { ...vm.$route.query };
if (vm.selected_brands.length > 0) {
q.brands = vm.selected_brands.join("-");
} else {
delete q.brands;
}
vm.$router.push({
name: "search-slug",
params: vm.$route.params,
query: q,
});
},