【发布时间】:2015-09-08 21:03:42
【问题描述】:
我看不懂库https://github.com/jquense/react-widgets 有一个路径,例如:lib/NumberInput.js
这个文件有代码:
'use strict';
var babelHelpers = require('./util/babelHelpers.js');
var React = require('react'),
CustomPropTypes = require('./util/propTypes'),
localizers = require('./util/configuration').locale;
var format = function format(props) {
return props.format || localizers.number.formats['default'];
};
//.... code code code .....
我的代码:
<!DOCTYPE html>
<html>
<head>
<title>Hello React</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/react.js"></script>
<script src="react-widgets/lib/NumberInput.js"></script>
</head>
<body></body>
</html>
在控制台写入错误:
Uncaught ReferenceError: require is not defined
我连接了图书馆。 http://requirejs.org/
<!DOCTYPE html>
<html>
<head>
<title>Hello React</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/react.js"></script>
<script src="require.js"></script>
<script src="react-widgets/lib/NumberInput.js"></script>
</head>
<body></body>
</html>
再次,我有一个错误:
未捕获的错误:模块名称“util/babelHelpers.js”尚未加载 然而对于上下文:_。使用 require([])
我做错了什么?
【问题讨论】: