动态传参(补)

502 阅读1分钟

query:

this.router.push({
    path:'/xxx',query:{id:id}
})
 接受参数: this.route.query.id

params:

this.$router.push({ name:'路由名称',params:{id:id} })

接受参数:this.$route.params.id

params传参,push只能是name:'xxx',不能是path

二者还有一点区别就是 query相当于get请求地址栏可以看到请求参数, params相当于post参数在地址栏不会显示

js: get请求会有缓存 post重新请求 get请求大小2kb