gpt4 book ai didi

javascript - 在 hello world 应用程序上 react 错误 "Uncaught TypeError: type.toUpperCase is not a function"

转载 作者:行者123 更新时间:2023-12-03 16:39:10 25 4
gpt4 key购买 nike

我已经开始涉足 reactjs,并且在按照教程进行操作时,我在标题上遇到了错误,只是在运行一个非常简单的 hello world 应用程序。下面是我的单页代码:

   <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="https://fb.me/react-0.13.3.js"></script>
<script src="https://fb.me/JSXTransformer-0.13.3.js"></script>
</head>
<body>
<script type="text/jsx">
// Define a class
var HelloWorld = React.createClass({
render: function() {
return <div>
Hello World!
</div>
}
});

// create element with this class
var element = React.createElement({HelloWorld});

// Render this class and place it in the body tag
React.render(element, document.body);
</script>
</body>

</html>

非常感谢任何提示或解决方案。

最佳答案

在我的例子中,我创建了一个 React 元素,但我忘记在文件末尾导出它:

var React = require('react');

var About = React.createClass({
render: function(){
return (
<div>
<h1>The about page</h1>
</div>
);
}
});
export {
About, About as default
};

关于javascript - 在 hello world 应用程序上 react 错误 "Uncaught TypeError: type.toUpperCase is not a function",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31598471/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com