Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
274 views
in Technique[技术] by (71.8m points)

javascript - 如何从Vue.js中的URL获取查询参数?(How can I get query parameters from a URL in Vue.js?)

How can I fetch query parameters in Vue.js?

(如何在Vue.js中获取查询参数?)

Eg http://somesite.com?test=yay .

(例如http://somesite.com?test=yay 。)

Can't find a way to fetch or do I need to use pure JS or some library for this?

(无法找到一种获取方式,或者我需要为此使用纯JS或某些库吗?)

  ask by Rob translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

According to the docs of route object , you have access to a $route object from your components, that expose what you need.

(根据route object的文档,您可以从组件中访问$route对象,从而暴露您的需求。)

In this case

(在这种情况下)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...