vue框架,在当前页面下,进行F5刷新后,跳转到指定的另一个页面,应该怎么做。
在你的vue项目app.vue的script 标签中加入下面的代码。
<script>
document.onkeydown=(event)=>{
if(event.keyCode===116){
event.preventDefault();
console.log('f5');
window.location="http://www.sina.com.cn";
//这里http://www.sina.com.cn 你可以替换成自己要跳转的url
}
}
</script>
刷新就会触发created函数 我们可以在里面去 router.push()去进行跳转