美文网首页
url的hash模式和html5的history模式异同

url的hash模式和html5的history模式异同

作者: 超超超喜欢大河 | 来源:发表于2020-05-02 00:46 被阅读0次

链接文章:https://blog.csdn.net/fifteen718/article/details/82529433
相同点:都不会实际上向后端发送请求。
不同点:
history模式里面push方法可以back,如果用replaceState的话不可以back,
history.go(-1)==pop。可以直接跳到push栈的某一步。
history.forward()==history.go(1)。

利用路由传递参数

params和query的区别
params:/user/:id,
取参数就是this.$route.params

query:
<router-link :to="{path:'/profile',query:{name:'why',age:18}}"></router-link>
$route.query.name

如果使用的是js跳转的话
this.$router.push({
path:"/profile",
query:{
name:"kobe",
age:19
}
})

导航守卫:
导航守卫分为前置守卫和后置守卫,
//跳转前回调,必须调用next()函数
router.beforeEach();
//跳转后回调,可以不调next()函数
router.afterEach();

相关文章

网友评论

      本文标题:url的hash模式和html5的history模式异同

      本文链接:https://www.haomeiwen.com/subject/htaqghtx.html