美文网首页
vue-router中params和query的区别

vue-router中params和query的区别

作者: 蜗牛和曼巴 | 来源:发表于2020-02-29 11:02 被阅读0次

学习交流QQ群:201575951

用法上的

query要用path来引入

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

params要用name来引入

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

展示上的

query在url中显示参数

http://localhost:8080/detail?type=0&detail=哈哈

params在url中不显示参数

http://localhost:8080/detail

相关文章

网友评论

      本文标题:vue-router中params和query的区别

      本文链接:https://www.haomeiwen.com/subject/ryvuhhtx.html