要使用React Router的Link组件链接到应用程序外部的URL,可以按照以下步骤进行操作:
npm install react-router-dom
import React from 'react';
import { Link } from 'react-router-dom';
<Link to="https://www.example.com">Go to external website</Link>
import React from 'react';
import { Link } from 'react-router-dom';
function App() {
return (
<div>
<h1>My App</h1>
<Link to="https://www.example.com">Go to external website</Link>
</div>
);
}
export default App;
使用以上步骤,你可以在React应用程序中使用Link组件链接到应用程序外部的URL。点击链接后,将会跳转到指定的外部网址。
领取专属 10元无门槛券
手把手带您无忧上云