关于网友提出的“ (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