vue实现动态改变地址栏的参数值
点击切换Tab,通过watch监听,在地址栏修改对应得active参数,这样刷新后还能保持最后浏览的tab
watch: {
active (newValue) {
let query = this.$router.history.current.query;
let path = this.$router.history.current.path;
//对象的拷贝
let newQuery = JSON.parse(JSON.stringify(query));
// 地址栏的参数值赋值
newQuery.active = newValue;
this.$router.push({ path, query: newQuery });
}
}