React-Native進行時(四)--ListView navigator.push
1、使用Nav時必須添加
TouchableHighlight、
NavigatorIOS;
var {
AppRegistry,
StyleSheet,
Text,
View,
NavigatorIOS,
TouchableHighlight,
} = React;
使用時nav必須有個rootView,這點iOS基本一緻 ,ios使用如下:
- (instancetype)initWithRootViewController:(UIViewController *)rootViewController
react-native使用如下:
<NavigatorIOS style={Style.container}
tintColor={'#333344'}
initialRoute={{
title: '忽悠',
component: require('./App/Views/Home/Home')
}}
itemWrapperStyle={Style.navigator} />
2、push使用這點和iOS不太一樣,iOS使用如下方法就可以實作:
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
react-native必須使用TouchableHighlight配合,代碼如下:
<TouchableHighlight onPress={() => this.showDetail(rsustlBody)} >
<View style={styles.container}>
<Image
source={{uri: rsustlBody.OtherInfo.ProductImg}}
style={styles.thumbnail}
/>
<View style={styles.rightContainer}>
<Text style={styles.title}>{rsustlBody.Name}</Text>
<Text style={styles.year}>{rsustlBody.BrokerCommissionRate}</Text>
</View>
</View>
</TouchableHighlight>
使用TouchableHighlight時,裡面必須要有View