我在运行react-native应用程序时也遇到了同样的问题.我使用的版本如下:
React-Native:0.57.1 react-native-cli:2.0.1 node:v8.11.3 npm:5.6.0
Babel版本详细信息:
"devDependencies":{"@ babel/runtime":"^ 7.0.0","babel-jest":"20.0.3","babel-preset-react-native":"^ 2.1.0","jest" ":"20.0.4","react-test-renderer":"16.0.0-alpha.12","schedule":"^ 0.4.0"},"jest":{"预设":"反应 - 原生"}}
错误:
错误:捆绑失败:类型错误:在Scope.moveBindingTo无法读取空的特性"绑定"(/home/manish/Desktop/Practice/donut/node_modules/@babel/traverse/lib/scope/index.js:867:13)在BlockScoping.updateScopeInfo(/home/manish/Desktop/Practice/donut/node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:364:17)在BlockScoping.run(/家/马尼什/桌面/实践/甜甜圈/ node_modules /巴别-插件 - 转换 - ES2015 - 嵌段 - 作用域/ LIB/index.js:330:12)在PluginPass.BlockStatementSwitchStatementProgram(/家庭/和Manish /桌面/实践/甜甜圈/ node_modules/babel- newFn中的plugin-transform-es2015-block-scoping/lib/index.js:70:24)(/home/manish/Desktop/Practice/donut/node_modules/@babel/traverse/lib/visitors.js:193:21 )在NodePath.all上的NodePath._call(/home/manish/Desktop/Practice/donut/node_modules/@babel/traverse/lib/path/context.js:53:20)(/ home/manish/Desktop/Practice/donut/node_modules/@babel/traverse/lib/path/context.js:40:17)在NodePath.visit(/ home/manish/Desktop/Pr)actice/donut/node_modules/@babel/traverse/lib/path/context.js:88:12)在TraversalContext.visitQueue(/家/马尼什/桌面/业务/甜甜圈/ node_modules/@通天塔/横/ lib中/上下文. js:118:16)BUNDLE [android,dev] ./ index.android.js░░░░░░░░░░░░░░░░0.0%(0/3):: ffff:127.0.0.1 - - [01/Oct/2018:05:31:17 +0000]"GET /index.android.delta?platform=android&dev=true&minify=false HTTP/1.1"500 - " - ""okhttp/3.10.0"BUNDLE [ android,dev]./index.android.js░░░░░░░░░░░░░░░░0.0%(0/3),失败了.
似乎错误是由于巴贝尔而来.但无法获得解决方案.这个问题的解决方案是什么?
我正在使用express.js、mongodb、react.js 和node.js 制作React 项目。并尝试从端口 5000 上运行的后端 api 获取数据。
当我使用 检查 api 时postman,它正在工作。数据显示在浏览器的控制台中。另外,当我按下Get下面代码中给出的按钮时,它在浏览器上不起作用。但我可以在浏览器的控制台中看到数组数据。
<Button onClick={()=><li>{employeeItem}</li>}>Get</Button>
这是我的完整代码:
import React, { Component } from "react";
import {
form,
FormGroup,
FormControl,
ControlLabel,
Button
} from "react-bootstrap";
import "./App.css";
import { stringify } from "querystring";
class App extends Component {
constructor(props) {
super(props);
this.AddName = this.AddName.bind(this);
this.AddContact = this.AddContact.bind(this);
this.AddAge = this.AddAge.bind(this);
this.state = {
name: "",
contact: "",
age: "",
employees: []
};
}
AddName(e) {
this.setState({ name: e.target.value }); …Run Code Online (Sandbox Code Playgroud)