代码之家  ›  专栏  ›  技术社区  ›  koque

为什么react不允许我在html列表项中使用路由器dom链接?

  •  0
  • koque  · 技术社区  · 4 年前

    <li className="nav-item">
      <Link to={'/cart'}>
        <i
          className="fa fa-shopping-bag"
          style={{fontSize: "22px"}}></i>
      </Link>
    </li>
    

    错误:

    index.tsx:19 Uncaught Error: useHref() may be used only in the context of a <Router> component.
    
    1 回复  |  直到 4 年前