表单分页,默认第一页,点击第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)
// })
posted @ 2019-03-12 12:48  小短腿奔跑吧  阅读(783)  评论(0编辑  收藏  举报