How to read URL query param value in vuejs

末鹿安然 提交于 2021-01-24 10:53:08

问题


In vuejs callback URL I've some parameter value and I need to read this param value. For example the return url is: http://localhost:8080/#/sucesspage?encryteddata=abdeshfkkilkalidfel&9a

I have tried this.$route.query.encryteddata but I'm got null value.

Is there any way to get the param value in vuejs?


回答1:


You should understand that Route Querys and Route Params in Vue are 2 different things. You declare Route params in your Router for example www.example.com/30 = /:id, then you can get that data via this.$route.params.id

The Url Querys usually look like www.example.com/hello?visible=false and you can grab those with

let urlParams = new URLSearchParams(window.location.search);
let myParam = urlParams.get('visible');

You can also combine these 2 for example getting on the Article with the ID of 30 while having a query telling you some other additional info. /30?visible=false



来源:https://stackoverflow.com/questions/52587549/how-to-read-url-query-param-value-in-vuejs

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!