首页 |  我的博客 |  查看该博主内容分类 | 

node vue如何修改进入网页时的query参数并显示在url上?

解决办法

beforeROuterEnter(to, from, next){
	next(vm => {
		if (from.fullPath !== '/'){  // 此处设定的条件,视情况变化,避免url无变化时$router.push的错误
			vm.$router.push({
				path: this.$route.path,
				query: {
					...this.$route.query,
					from: from.fullPath,
				}
			})
		}
	})
}

该方法可用于进入网页时,保留来源于的url

posted @ 2023-11-16 10:11  Z哎呀  阅读(24)  评论(0)    收藏  举报