How can I get query parameters from a URL in Vue.js?

后端 未结 9 1516
甜味超标
甜味超标 2020-12-12 13:47

How can I fetch query parameters in Vue.js?

E.g. http://somesite.com?test=yay.

Can’t find a way to fetch or do I need to use pure JS or some lib

9条回答
  •  心在旅途
    2020-12-12 14:48

    If your url looks something like this:

    somesite.com/something/123
    

    Where '123' is a parameter named 'id' (url like /something/:id), try with:

    this.$route.params.id
    

提交回复
热议问题