[英]How to Redirect to a new page like www.google.com in ReactJS like click a button window.location.href
Hallo I am new to React and here. 哈o我是React的新手,在这里。
I have questiona about redirect to an URL in React. 我有关于重定向到React中URL的问题。 I am wondering if I can make React page redirect to another URL like www.google.com I did it like .
我想知道是否可以使React页面重定向到我这样做的另一个URL,例如www.google.com。
<a href='http://localhost:8000/api?issuer=ideal_KNABNL2H'>Go to Pay</a>
<button onclick="window.location.href='http://www.google.com'">
But it doen't work at React. 但是它在React上不起作用。 Can it be done in react-router?
可以在react-router中完成吗? I have read its doc, still don't know how to make it.
我已经阅读了它的文档,但仍然不知道如何制作。
这对我来说很好
<button onClick={() => window.open( 'http://www.google.com')} >google</button>
您不需要为此:)
<a href="https://www.google.com/"><button>Visit google</button></a>
<MyLink link="http://www.google.com" title="Google"/>
If it is to redirect to another page, enter http, but if it is to access screen in the project it is used React Router 如果要重定向到另一个页面,请输入http,但是如果要访问项目中的屏幕,则使用React Router。
npm install react-router-dom
npm install react-router-dom
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.