即使已导入包,也找不到组件
Component is not found even though package has been imported
我已经需要包(react 和 belle),但是在分配它时,它会抛出一个未找到的错误。
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
导入 TextInput 时缺少 var。变化
TextInput = belle.TextInput;
至
var TextInput = belle.TextInput;
我已经需要包(react 和 belle),但是在分配它时,它会抛出一个未找到的错误。
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
导入 TextInput 时缺少 var。变化
TextInput = belle.TextInput;
至
var TextInput = belle.TextInput;