即使已导入包,也找不到组件

时间:2015-08-02 19:16:09

标签: reactjs babeljs

我已经需要包(反应和美女),但在分配时,它会抛出一个未找到的错误。

belle.html

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.6.15/browser.js"></script>
  <script src="node_modules/babel-core/browser.js"></script>
</head>
<body>
  <div id="react-root"></div>
  <!--
    You can use browserify, webpack or similar tools
    to compile & combine your JSX code
  -->
  <script src="bundle.js"></script>
</body>
</html>

belle.jsx

var React = require('react');
var belle = require('belle');
TextInput = belle.TextInput;

var App = React.createClass({

  render: function () {
    return <div>
      <TextInput defaultValue="Update here and see how the input grows …" />
    </div>;
  }
})

React.render(<App/>, document.getElementById('react-root'));

我已经安装了依赖项并保存了它们但是我一直收到这个错误:

Uncaught ReferenceError: TextInput is not defined1.belle @ bundle.js:6s @ bundle.js:1e @ bundle.js:1(anonymous function) @ bundle.js:1

1 个答案:

答案 0 :(得分:2)

导入 TextInput 时,您缺少 var 。变化

TextInput = belle.TextInput;

var TextInput = belle.TextInput;