记录日常:
一、标签跳转
<router-link to="...">
:跳转到不同的url,这个方法会向history栈添加一个记录;点击后退会返回到上一个页面;
<router-link to="...">
和push方法是一样的
二、方法跳转
this.$router.push()
: 跳转到不同的url,这个方法会向history栈添加一个记录,点击后退会返回到上一个页面;
如:this.$router.push('/index')
push方法和<router-link to="...">
是一样的。this.$router.replace()
: 也是用在页面跳转;但是他不会记录在history栈中;也就是说,它不会出现在history列表中;并且按返回是返回不到这个页面this.$router.go(n)
: n可为正数可为负数;类似javascript 中的页面跳转window.history.go(n)
this.$router.go(1) //类似window.history.forward()--->加载history 列表中的下一个 URL
this.$router.go(-1) //类似window.history.back()--->加载 history 列表中的上一个 URL