您好,欢迎来到[编程问答]网站首页   源码下载   电子书籍   软件下载   专题
当前位置:首页 >> 编程问答 >> Web开发 >> (vue.js)vue-router 路由怎么匹配 indexhtml?type=1 中type=n变化?

(vue.js)vue-router 路由怎么匹配 indexhtml?type=1 中type=n变化?

来源:网络整理     时间:2016/8/28 22:40:55     关键词:

关于网友提出的“ (vue.js)vue-router 路由怎么匹配 indexhtml?type=1 中type=n变化?”问题疑问,本网通过在网上对“ (vue.js)vue-router 路由怎么匹配 indexhtml?type=1 中type=n变化?”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:

问题: (vue.js)vue-router 路由怎么匹配 indexhtml?type=1 中type=n变化?
描述:

比如url为index.html,index.html?type=1 和 index.html?type=2三个页面
vue-router怎么监听后面type=1,type=2和没有type的页面,让页面刷新?


解决方案1:

就是不爱看文档

http://router.vuejs.org/zh-cn...

vue-router 里面靠的是

route: {
  data: function () {
       在这里去你的type  this.$route.query
  }
}
解决方案2:

设置一个data然后赋值为这个type值,然后再监听这个data的变化

主要代码如下:

data() {
  return {
    type: 0,
  }
},
watch: {
  type(val, oldVal) {
    // 变化后做的处理
  }
},
created() {
  this.type = this.$route.query.type;
}

以上介绍了“ (vue.js)vue-router 路由怎么匹配 indexhtml?type=1 中type=n变化?”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/3641093.html

相关图片

相关文章