Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
230 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 Answer

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'

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...