代码this
this.$router.push({ path: '/container', params: { url: this.func.url, }, });
在跳转后的页面中console.log(this.route)
发现params是空的url
问题缘由:用法错误,如下为正确用法code
this.$router.push({ name: 'container', params: { url: this.func.url, }, });
要使跳转后的页面this.$route.params
有参数,必须使用name:'container'
,而不是path:'/container'
,还须要注意name中没有/
router
this.$router.push({ name: 'container', params: { url: this.func.url, }, });
参数获取this.$route.params.url
console
this.$router.push({ path: '/container', query: { url: this.func.url, }, });
这种方式会在跳转的地址上拼接上?url=xxxx
获取方式this.$route.query.url
注意区别两种方式,切勿path和name同时出现route