在React Native中使用decorator,可以't find变量:require
Using decorators in React Native, can't find variable: require
我正试图在我的RN项目中使用装饰器:
以下是我的package.json文件:
{
"name": "testApp",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start"
},
"dependencies": {
"autobind-decorator": "^1.3.3",
"babel-core": "^6.7.4",
"babel-loader": "^6.2.4",
"babel-plugin-transform-class-properties": "^6.6.0",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-runtime": "^6.6.0",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"babel-preset-react-native": "^1.5.6",
"babel-preset-stage-0": "^6.5.0",
"babel-runtime": "^6.6.1",
"react": "^0.14.8",
"react-native": "^0.22.2",
"webpack": "^1.12.14"
}
}
这是我的。babelrc:
{
"plugins": [
"transform-runtime",
"transform-decorators-legacy",
"transform-class-properties"
],
"presets": ["es2015", "react", "stage-0", "react-native"]
}
我在陈述ReferenceError: Can't find variable: require
时出错。我尝试了很多帖子,但都没有得到任何解决方案。我使用react-native init testApp
创建了新的RN项目
修复错误是因为预设的顺序:我删除了所有其他预设,并将预设更改为"本地反应",现在一切正常。
相关文章:
- 将函数的上下文应用于javascript变量
- 无法导出函数expressjs/requestjs中的变量
- 函数参数中的数据与指定变量之间的任何性能差异
- 将PHP变量传递给jQuery时遇到问题
- 如何通过ajax刷新JSF填充的javascript变量
- 参数变量出现ngTable指令问题
- 通过javascript重定向html传递php变量
- 将jsp文件下拉列表中的选定项分配给一个java变量(比如String selection)
- 当变量中的.find()项有多个匹配项时,jQuery问题
- 有没有一种方法可以在mongoose中的find()中使用变量作为字段名
- 在React Native中使用decorator,可以't find变量:require
- 使用 .find() 以多类为目标,将当前类存储为变量
- 快递.js+猫鼬.find() 不传递已定义变量的结果
- 在Find中使用Mongo JavaScript中的变量
- Meteor find使用变量返回null
- 因果报应:Can't find变量:exports
- 将变量作为参数的函数find()返回空对象
- 处理nodejs中mongo collection.find()变量的模板访问
- 可以't find变量:React
- 使用getScript-ReferenceError加载google API:Can't find变量:谷歌