ReactJS Navigation: Open Links in New Tab with target='_blank'
{"title":"ReactJS Navigation: Open Links in New Tab with target='_blank'","description":"Learn how to open ReactJS navigation links in a new tab using the 'target='_blank'' attribute. This guide provides a simple code example and explanation for easy implementation.","keywords":"reactjs, navigation, target _blank, new tab, react-router-dom, link component, web development","content":"In React, you can open navigation links in a new tab by setting the "target="_blank"" attribute. Here's an example:
import React from \'react\';
import { Link } from \'react-router-dom\';
const MyComponent = () => {
return (
<div>
<Link to=\"/\" target=\"_blank\">Go Home</Link>
</div>
);
}
export default MyComponent;
In the above example, we use the "Link" component from the "react-router-dom" library to create a navigation link and set the "target="_blank"" attribute, which causes the link to open in a new tab."}
原文地址: https://www.cveoy.top/t/topic/pTrE 著作权归作者所有。请勿转载和采集!