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

后端 未结 9 1500
甜味超标
甜味超标 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:52

    According to the docs of route object, you have access to a $route object from your components, which exposes what you need. In this case

    //from your component
    console.log(this.$route.query.test) // outputs 'yay'
    

提交回复
热议问题