我收到以下错误:
TypeError:undefined不是对象(正在评估“ RNLANScan.scan”)
我做了:
博览会博览会
我做了所有步骤,就像自述文件在此链接中所述:
https://github.com/Odinvt/react-native-lanscan
我对位于以下位置的文件进行了更改:
'appName'\ android \ build.gradle
'appName'\ android \ settings.gradle
'appName'\ android \ app \ src \ main \ java \ host \ exp \ exponent \ MainActivity.java
链接到资源库中的问题:
https://github.com/Odinvt/react-native-lanscan/issues/8
import React, { Component } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { LANScan } from 'react-native-lanscan';
export default class App extends Component {
constructor(props){
super(props)
let lanscan = new LANScan();
if(lanscan !== null){
console.log('not null');
lanscan.scan(48500, 48503, 100, true, 20, 100);
lanscan.on('end_pings', () => {
let connected_hosts = lanscan.getConnectedHosts();
// connected_hosts = ["192.168.1.10", "192.168.1.15"]
// if 192.168.1.10 & 192.168.1.15 responded to the pings.
console.log(connected_hosts);
});
}else{
console.log('null again');
}
}
render(){
return (
<View style={styles.container}>
<Text>Open up App.js to start working on your app!</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
应用未运行,出现以下错误:
TypeError:undefined不是对象(正在评估“ RNLANScan.scan”)