原vue-router中params和query的区别

Posted peunzhang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了原vue-router中params和query的区别相关的知识,希望对你有一定的参考价值。

1.引入方式不同

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

params要用name来引入

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

 





以上是关于原vue-router中params和query的区别的主要内容,如果未能解决你的问题,请参考以下文章