js实现后退、前进、刷新
1. 返回上一页(-1不是返回一个,-2不是返回两个)
- window.history.go(-1);
区别:go方式会返回并保留数据(如表单中的数据)。 - window.history.back(-1);
区别:back方式会返回并刷新数据。
2. 前进一页
- window.history.go(1);
- window.history.forward();
3. 刷新
- window.location.reload();
vue路由跳转到上一次的页面
//this.$router.go(-1)
//指定跳转的地址
//this.$router.replace('/learn')
//指定跳转路由的名字下
//this.$router.replace({name:'menuLink'})
//通过push进行跳转
this.$router.push("/learn");
//this.$router.push({name:'/learn'})
总结:
<input type=button value=刷新 οnclick="window.location.reload()">
<input type=button value=前进 οnclick="window.history.go(1)">
<input type=button value=后退 οnclick="window.history.go(-1)">
<input type=button value=前进 οnclick="window.history.forward()">
<input type=button value=后退 οnclick="window.history.back()"> //后退+刷新