vue-router
请求方式我们知道有两种(get/post),对应的路由跳转和传递参数的方式也不同
路由跳转有四种
router-link和router-view对应
this.$router.push({})
上面两种会把路由的跳转记录到history栈中去,可以回退,后两种没法回退到上一步路由
this,$router.replace()
this.$router.go(n) n为整数(正数代表向前跳转,负数代表向后)
this.$router.push()传递参数也有经典的两种,混淆起来就很难分清
this.$router.push({
name:'Home',
params:{}
})
这一种类似与post请求,name与path作用类同,不像get请求是将参数拼接在地址栏后面
this.$router.push({
path:'',
query:''
})
类似于get请求,安全性不高
this.$router相当于是项目的全局路由对象
this.$routes是所有的路由规则的定义