获取URL中的数值
获取路由对象
现在有一串URL
http://localhost:8080/home?code=1234753
需求: 获取其中的 code = XXX 的值
this.$route.query.code
路由有可能会出现未能加载完成路由导致无法获取的错误
升级写法: 使用 onReady(内置的路由加载完成函数)
this.$router.onReady(() => {
console.log(this.$route.query.code);
})
刷新当前页面
this.$router.push(this.$route.path)