首页 > vue-router 路由怎么匹配 index.html?type=1 中type=n变化?

vue-router 路由怎么匹配 index.html?type=1 中type=n变化?

比如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
  }
}
【热门文章】
【热门文章】