比如url为index.html,index.html?type=1 和 index.html?type=2三个页面
vue-router怎么监听后面type=1,type=2和没有type的页面,让页面刷新?
设置一个data
然后赋值为这个type
值,然后再监听这个data
的变化
主要代码如下:
data() {
return {
type: 0,
}
},
watch: {
type(val, oldVal) {
// 变化后做的处理
}
},
created() {
this.type = this.$route.query.type;
}
就是不爱看文档
http://router.vuejs.org/zh-cn...
vue-router 里面靠的是
route: {
data: function () {
在这里去你的type this.$route.query
}
}