提交 23c1222a 编写于 作者: A afc163

global require for demo code

上级 ced4dcb9
......@@ -7,7 +7,7 @@
---
````jsx
var Breadcrumb = antd.Breadcrumb;
var Breadcrumb = require('antd/components/breadcrumb');
React.render(
<Breadcrumb>
......
# BreadCrumb
# Breadcrumb
- category: Components
- chinese: 面包屑
......
......@@ -6,6 +6,32 @@
{% block scripts %}
<script src="/dist/antd.js"></script>
<script>
window.require = function(path) {
var result = window;
if (path.indexOf('antd') < 0 ||
path.indexOf('antd/components/') < 0) {
throw 'There should not have modules here 1.';
}
var namespaces = path.split('/');
namespaces.forEach(function(key, i) {
if (i === namespaces.length - 1) {
key = capitalizeFirstLetter(key);
}
if (key !== 'components') {
if (result[key]) {
result = result[key];
} else {
throw 'There should not have modules here 2.';
}
}
});
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
return result;
};
</script>
{% endblock %}
{% block aside %}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册