正在看这篇教程: https://www.meteor.com/tutorials/react/components
在 2.4 的 imports/ui/App.jsx 文件里面,有这么一个函数:
getTasks() {
return [
{ _id: 1, text: 'This is task 1' },
{ _id: 2, text: 'This is task 2' },
{ _id: 3, text: 'This is task 3' },
];
}
这个简单函数的作用仅仅只是返回一个数组,于是我就想 [为什么不直接定义一个数组呢] ?像范例这样定义一个函数,再让这个函数返回一个数组,这不是脱裤子放屁吗?你不就想要一个数组吗?于是我就直接在这个函数的上面定义一个 tasksList 数组:
let tasksList = [
{ _id: 1, text: 'This is task 1' },
{ _id: 2, text: 'This is task 2' },
{ _id: 3, text: 'This is task 3' },
];
这么定义之后, Meteor 就报错了(其他代码都没动)。这是为什么呢?我知道我定义的数组下面没有用到,但是没用到也不至于就报错吧,求指点。
Meteor 报错信息如下:
While building for web.brower:
imports/ui/App.jsx:8:6 Unexpected token (8:6)
=> Your application has errors. Waiting for file change.