表单分页,默认第一页,点击第5页,返回,如何跳转到第1页

<button @click="buttonClick"></button>

//点击事件

buttonClick(){
  window.history.replaceState({index: 2}, null, window.location.href)
  //window.history.pushState({index: 2}, null, window.location.href)
  this.$router.push({name: 'parsem'})
}
//默认事件
window.onpopstate = function (params) {
  console.log('location: ' + document.location);
  console.log('state: ' + params.state);
}
//或者一下
// window.addEventListener('popstate', function (params) {
//   console.log(params.state)
// })
原文地址:https://www.cnblogs.com/gqx-html/p/10515975.html