Problema: al hacer clic en el enlace, la dirección está analizando el valor de las propiedades "a" del enlace en react-router-dom, consulte el resultado: http://localhost:3000/https://xxxxxx.github .io/
import React from 'react'; import { Link } from 'react-router-dom'; const Footer = () => { return ( <footer className='footer-light bg-light'> <div className='text-center p-3' > <Link className='text-decoration-none text-dark' to='https://xxxxxxx.github.io/' > © {new Date().getFullYear()} Copyright </Link> </div> </footer> ); }; export default Footer;Quiero redirigir a otra página al hacer clic en el enlace
Puede pasar una cadena, un objeto o una función a to prop para redirigir a una URL específica.
Aquí está cómo hacer con cada uno de ellos
Cadena :
<Link to="https://google.com">Click me</Link>Objeto :
<Link to={{ pathname: "https://google.com" }} target="_blank">Click me</Link>Función :
<Link to={location => ({ ...location, pathname: "https://google.com" })} />Funciona tanto para URL externas como para localhost.
Documentos: https://reactrouter.com/web/api/Link
puedes probar esto:
<Link to={{ pathname: "https://xxxxxxx.github.io/" }} target="_parent" rel="noopener noreferer"> © {new Date().getFullYear()} Copyright </Link>esto abrirá https://xxxxxxx.github.io/ en la misma pestaña.
o,
<Link to={{ pathname: "https://xxxxxxx.github.io/" }} target="_blank" rel="noopener noreferer"> © {new Date().getFullYear()} Copyright </Link>esto será https://xxxxxxx.github.io/ en una nueva pestaña.