require antd

pull/30/head
afc163 10 years ago
parent d38c6536ae
commit db30835c0e

@ -7,7 +7,7 @@
--- ---
````jsx ````jsx
var Breadcrumb = require('antd/components/breadcrumb'); var Breadcrumb = require('antd/lib/breadcrumb');
React.render( React.render(
<Breadcrumb> <Breadcrumb>

@ -7,7 +7,7 @@
--- ---
````jsx ````jsx
// or require('antd/components/datepicker'); // or require('antd/lib/datepicker');
var Datepicker = antd.Datepicker; var Datepicker = antd.Datepicker;
React.render( React.render(

@ -85,6 +85,8 @@ React.render(<MyPage />, document.body);
> `var Datepicker = require('antd/lib/Datepicker')` 单独引入需要的组件文件可以有效减少最终构建文件的大小。 > `var Datepicker = require('antd/lib/Datepicker')` 单独引入需要的组件文件可以有效减少最终构建文件的大小。
> `lib` 即构建后的 `components` 目录。
然后建一个页面用于开发。 然后建一个页面用于开发。
```bash ```bash

@ -6,7 +6,7 @@
window.require = function(path) { window.require = function(path) {
var result = window; var result = window;
if (path.indexOf('antd') < 0 || if (path.indexOf('antd') < 0 ||
path.indexOf('antd/components/') < 0) { path.indexOf('antd/lib/') < 0) {
throw 'There should not have modules here 1.'; throw 'There should not have modules here 1.';
} }
var namespaces = path.split('/'); var namespaces = path.split('/');
@ -14,7 +14,7 @@ window.require = function(path) {
if (i === namespaces.length - 1) { if (i === namespaces.length - 1) {
key = capitalizeFirstLetter(key); key = capitalizeFirstLetter(key);
} }
if (key !== 'components') { if (key !== 'lib') {
if (result[key]) { if (result[key]) {
result = result[key]; result = result[key];
} else { } else {

Loading…
Cancel
Save