-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathFirstPageComponent.js
49 lines (43 loc) · 1.22 KB
/
FirstPageComponent.js
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
47
48
49
'use strict';
var React = require('react-native');
var {
View,
Text,
TouchableOpacity
} = React;
var SecondPage = require('./SecondPageComponent');
var FirstPageComponent = React.createClass({
getInitialState: function() {
return {
id:85,
};
},
componentDidMount: function() {
},
_pressButton: function() {
//const { navigator } = this.props;
const nvi = this.props.navigator;
//为什么这里可以取得 props.navigator?请看上文:
//<Component {...route.params} navigator={navigator} />
//这里传递了navigator作为props
if(nvi) {
nvi.push({
name: 'SecondPage',
component: SecondPage,
params:{
id:this.state.id
}
})
}
},
render: function() {
return (
<View>
<TouchableOpacity onPress={this._pressButton} style={{width: 1000, height: 400, backgroundColor: '#000000'}}>
<Text style={{color:'blue'}}>点我跳转并传递ID</Text>
</TouchableOpacity>
</View>
);
}
});
module.exports = FirstPageComponent;