gpt4 book ai didi

meteor - Meteor React.js 教程第 2 部分中的应用程序崩溃

转载 作者:行者123 更新时间:2023-12-03 13:35:39 26 4
gpt4 key购买 nike

我的应用程序在 Meteor React.js 中崩溃(如下)tutorial 。我似乎找不到问题,代码完全来自教程。救命!

Desktop/simple-todos-react/.meteor/local/build/programs/server/app/simple-todos-react.js:14
React.render(<App />, document.getElementById("render-target")); // 6
^
SyntaxError: Unexpected token <
at Desktop/simple-todos-react/.meteor/local/build/programs/server/boot.js:241:30
at Array.forEach (native)
at Function._.each._.forEach (/.meteor/packages/meteor-tool/.1.1.9.1u3q681++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
at /Desktop/simple-todos-react/.meteor/local/build/programs/server/boot.js:137:5
Exited with code: 8
Your application is crashing. Waiting for file change.

simple-todos-react.html

<head>
<title>Todo List</title>
</head>

<body>
<div id="render-target"></div>
</body>
<小时/>

简单-todos-react.js

if (Meteor.isClient) {
// This code is executed on the client only

Meteor.startup(function () {
// Use Meteor.startup to render the component after the page is ready
React.render(<App />, document.getElementById("render-target"));
});
}
<小时/>

App.jsx

// App component - represents the whole app
App = React.createClass({
getTasks() {
return [
{ _id: 1, text: "This is task 1" },
{ _id: 2, text: "This is task 2" },
{ _id: 3, text: "This is task 3" },
{ _id: 4, text: "This is task 4" },
{ _id: 5, text: "This is task 5" }
];
},

renderTasks() {
return this.getTasks().map((task) => {
return <Task key={task._id} task={task} />;
});
},

render() {
return (
<div className="container">
<header>
<h1>Todo List</h1>
</header>

<ul>
{this.renderTasks()}
</ul>
</div>
);
}
});
<小时/>

任务.jsx

// Task component - represents a single todo item
Task = React.createClass({
propTypes: {
// This component gets the task to display through a React prop.
// We can use propTypes to indicate it is required
task: React.PropTypes.object.isRequired
},
render() {
return (
<li>{this.props.task.text}</li>
);
}
});
<小时/>

最佳答案

哇,忘记在文件名末尾添加“x”。应该是“simple-todos-react.jsx”。如果错误消息更清晰的话会有帮助。

关于meteor - Meteor React.js 教程第 2 部分中的应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33112233/

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