在 JavaScript 中,使用 router.push 方法通常用于跳转到新的页面,但如果需要在当前页面进行跳转,可以使用 window.location.href 或者 window.location.replace 方法。

使用 window.location.href 方法:

function toList() {
  console.log('按下了返回上一页的按钮');
  window.location.href = 'VerifyList.html';
}

使用 window.location.replace 方法:

function toList() {
  console.log('按下了返回上一页的按钮');
  window.location.replace('VerifyList.html');
}

这两种方法都会在当前页面加载新的 URL,实现跳转效果。

JavaScript 在当前页面跳转方法