@aarmour/console-react-poc 中文文档教程

发布于 9年前 浏览 22 更新于 3年前

Installation

npm + webpack/browserify

使用 npm 安装:

$ npm install --save react react-dom @aarmour/console-react-poc

然后在您的项目中导入模块:

import React from 'react';
import ReactDOM from 'react-dom';
import { course } from '@aarmour/console-react-poc';

const { CourseList } = course;

function App(props) {
  return <CourseList courses={[...]} />;
}

ReactDOM.render(<App />, document.getElementById('root'));

请注意,该项目使用 CSS 模块,因此您需要使用适当的 配置您的捆绑器加载器插件。 请参阅示例 以获得帮助。

UMD

umd 目录中还有一个 UMD 构建。 如果您直接从这个存储库的克隆工作,您可以使用以下方法生成 UMD 包:

$ npm run build-umd

构建一个缩小版本:

$ npm run build-min

然后在您的项目中导入模块:

// Using an es2015 transpiler
import { course } from 'umd/components';

const CourseList = course.CourseList;

// Using globals
var CourseList = window.Components.course.CourseList;

What's up with the src and lib directories?

模块源保存在 src 目录中使用 JSXES2015 编写。 为了让您不必在构建过程中添加转译步骤,我们会为您处理。 转译后的输出保存在 lib 目录中,您可以直接从那里导入模块:

import CourseList from '@aarmour/console-react-poc/lib/course/CourseList';

Running the demo locally

git clone https://github.com/aarmour/console-react-poc.git
cd console-react-poc
npm install
npm start

Acknowledgements

这个项目的构建过程改编自 rackt/react-router,版权所有 (c) 2015 Ryan Florence, Michael Jackson。

Installation

npm + webpack/browserify

Install using npm:

$ npm install --save react react-dom @aarmour/console-react-poc

Then import the module in your project:

import React from 'react';
import ReactDOM from 'react-dom';
import { course } from '@aarmour/console-react-poc';

const { CourseList } = course;

function App(props) {
  return <CourseList courses={[...]} />;
}

ReactDOM.render(<App />, document.getElementById('root'));

Note that this project uses CSS Modules, so you will need to configure your bundler with the appropriate loader or plugin. See the examples for help.

UMD

There is also a UMD build in the umd directory. If you are working directly from a clone of this repository, you can generate the UMD bundle using:

$ npm run build-umd

To build a minified version:

$ npm run build-min

Then import the module in your project:

// Using an es2015 transpiler
import { course } from 'umd/components';

const CourseList = course.CourseList;

// Using globals
var CourseList = window.Components.course.CourseList;

What's up with the src and lib directories?

The module source is kept in the src directory and is written using JSX and ES2015. To spare you from having to add a transpile step in your build process, we handle it for you. The transpiled output is kept in the lib directory, and you can import modules directly from there:

import CourseList from '@aarmour/console-react-poc/lib/course/CourseList';

Running the demo locally

git clone https://github.com/aarmour/console-react-poc.git
cd console-react-poc
npm install
npm start

Acknowledgements

The build process for this project was adapted from rackt/react-router, Copyright (c) 2015 Ryan Florence, Michael Jackson.

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文