【原】vue-router中params和query的区别

1.引入方式不一样

query要用path来引入
this.$router.push({
    path: 'test',
    query: {
        type: 2,
        detail: '哈哈'
    }
})

params要用name来引入this

this.$router.push({
    name: 'test',
    query: {
        type: 2,
        detail: '哈哈'
    }
})

 

2.url不一样

query在url中显示参数
http://localhost:8080/detail?type=0&detail=哈哈
params在url中不显示参数
http://localhost:8080/detail
相关文章
相关标签/搜索