Vue.js 中使用路由跳转到当前页面
要在当前页面进行路由跳转,可以使用'this.$router.push()'方法。在 Vue 组件中,可以通过'this.$router.push()'方法进行路由跳转。
以下是将代码中的'router.push()'替换为'this.$router.push()'的示例:
function toList() {
console.log('按下了返回上一页的按钮');
this.$router.push({
name: "VerifyList",
});
}
请确保在 Vue 组件中使用该方法,因为'this.$router'是 Vue 的实例属性。如果在全局作用域中使用该方法,需要通过'Vue.prototype.$router'访问路由实例。
AI 优化版
原文地址:https://www.cveoy.top/t/topic/qFpk 著作权归作者所有。请勿转载和采集!