Javascript React Native TypeError:无法读取属性';createClient';未定义的
我不熟悉React原生框架。我已使用“创建反应本机应用程序AwesomeProject”创建了应用程序。我想在我的项目中使用BLE,所以我安装了“react native BLE plx”模块,但当我创建BleManager实例时,它抛出错误TypeError:无法读取未定义的属性“createClient”。为什么它会抛出这个错误?我的App.js是:Javascript React Native TypeError:无法读取属性';createClient';未定义的,javascript,react-native,jsx,Javascript,React Native,Jsx,我不熟悉React原生框架。我已使用“创建反应本机应用程序AwesomeProject”创建了应用程序。我想在我的项目中使用BLE,所以我安装了“react native BLE plx”模块,但当我创建BleManager实例时,它抛出错误TypeError:无法读取未定义的属性“createClient”。为什么它会抛出这个错误?我的App.js是: import React from "react"; import { StyleSheet, Button, Text, View, Ale
import React from "react";
import { StyleSheet, Button, Text, View, Alert } from "react-native";
import { BleManager } from 'react-native-ble-plx';
export default class App extends React.Component {
constructor() {
super();
this.manager = new BleManager();
}
TestFunction() {
Alert.alert('Button Pressed !!!')
}
render() {
return (
<View style={styles.container}>
<Button onPress={ this.TestFunction } title="Learn
More"color="#841584" />
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center"
}
});
从“React”导入React;
从“react native”导入{样式表、按钮、文本、视图、警报};
从'react native ble plx'导入{BleManager};
导出默认类App扩展React.Component{
构造函数(){
超级();
this.manager=新的BleManager();
}
TestFunction(){
警报。警报('按钮按下!!!')
}
render(){
返回(
);
}
}
const styles=StyleSheet.create({
容器:{
弹性:1,
背景颜色:“fff”,
对齐项目:“中心”,
为内容辩护:“中心”
}
});
添加this.manager=new BleManager()在项目文件夹中的componentDidMount()中执行以下操作:
npm install --save react-native-ble-plx
react-native link react-native-ble-plx
请按照此处的说明操作:
这里还有一个示例项目:我这样做了。manager=new blemanger();在componentDidMount()中。但它仍然抛出了一个错误,我面临着同样的问题。如果您能找到解决方案,请发布答案。谢谢