【原】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





猜你喜欢

转载自www.cnblogs.com/PeunZhang/p/12090469.html