1 vue-router中params和query的区别
- query要用path来引入,并且url中含有参数,类似get请求。
this.$router.push({
path: 'test',
query: {
type: 2,
detail: '哈哈'
}
})
URL为http://localhost:8080/detail?type=0&detail=哈哈
- params要用name来引入,url中没有参数,类似post请求。
this.$router.push({
name: 'test',
params: {
type: 2,
detail: '哈哈'
}
})
URL为http://localhost:8080/detail