-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp4.js
More file actions
46 lines (44 loc) · 1.43 KB
/
App4.js
File metadata and controls
46 lines (44 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { NavigationContainer } from '@react-navigation/native'
import { createStackNavigator } from '@react-navigation/stack'
import React, { Component } from 'react'
import { Text, View } from 'react-native'
import WebView from 'react-native-webview'
let Stack=createStackNavigator
class Login extends Component{
_recieve=msg=>{
let user=JSON.stringify(msg.nativeEvent.data)
this.props.navigation.navigate('Suc',{user})
}
render(){
return <View>
<WebView onMessage={this._recieve} source={{uri:'http://192.168.31.165:3000/login.html'}}/>
</View>
}
}
class Suc extends Component(){
state={user:[]}
componentDidMount(){
let user=this.props.route.params.user
this.setState({user})
}
_script=()=>'alart(100)'
rander(){
let rs=JSON.stringify(this.state.user)
let script=`show('${rs}')`
return <View style={{flex:1}}>
<WebView injectedJavaScript={script} source={{uri:'http://192.168.31.165:3000/Suc.html'}}/>
</View>
}
}
export default class App4 extends Component {
render() {
return (
<NavigationContainer>
<Stack.Nacigator initialRouteName="Login">
<Stack.Screen name="Login" component={Login}/>
<Stack.Screen name="Suc" component={Suc}/>
</Stack.Nacigator>
</NavigationContainer>
)
}
}