【问题标题】:How to import react app from GitHub as a component to new react app?如何将 GitHub 中的 react 应用程序作为组件导入到新的 react 应用程序中?
【发布时间】:2019-12-06 22:55:45
【问题描述】:

如何从我的 GitHub 帐户导入 React 应用,作为新 React 应用的组件?

例如,我构建了一个NavBar 的 React 应用,并将其上传到 GitHub。我想将这个 NavBar 应用程序作为组件导入到新 React 项目的头组件中。

【问题讨论】:

    标签: reactjs github npm yarnpkg


    【解决方案1】:

    试试这个:

    npm install git://github.com/username/repo.git#branch-name
    
    yarn add git://github.com/username/repo.git#branch-name
    
    // Example
    yarn add git://github.com/denvash/react-pagination-example.git#master
    

    然后根据repo路径导入,例如:

    import Pagination from 'react-pagination/src/components/Pagination.react'
    

    【讨论】:

    • 现在我想我需要一个节点模块。
    【解决方案2】:

    尝试通过以下方式使用 npm 安装包:

    npm install --save your_repo_url/master
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-09
      • 1970-01-01
      • 2019-09-21
      • 1970-01-01
      • 1970-01-01
      • 2020-10-09
      • 2018-08-26
      • 2017-12-12
      相关资源
      最近更新 更多