小编ars*_*lan的帖子

为什么我的 React 应用程序将外部 URL 附加到 http://localhost:/<port> 而不仅仅是 URL 本身?

在我的 ReactJS 应用程序 (create-react-app) 中,我有一个锚标记,带有指向外部 URL www.google.com 的旧 href 属性,当我单击该 DOM 元素时,该应用程序会将目标 URL 附加到的HTTP://本地主机:3000和URI变为HTTP://本地主机:3000 / www.google.com

我错过了什么?

我尝试过设置rel={'external'}并尝试处理它onClick={()=>{window.location.assign("www.google.com")}

import React from "react";
import {NavLink, Redirect} from "react-router-dom";
import TextLink from "../textLink/TextLink";
import "./footer.css";


/**
 *
 * @param {{theme: string}} props
 */
const Footer = props => {
  const { theme } = props;
  return (
        <div className={`footer footer-${theme}`}>
          <div className="wrapper">

            <div id="social-media-icons">
              <NavLink to={"/contact-us"}>
              <i className="fab fa-facebook" />
              </NavLink>


              <a rel={'external'} className="fab fa-instagram" href={"www.google.com"} …
Run Code Online (Sandbox Code Playgroud)

reactjs react-router-dom

4
推荐指数
1
解决办法
1895
查看次数

标签 统计

react-router-dom ×1

reactjs ×1