我正在与 Mosh 一起学习 React Native 课程(https://codewithmosh.com/)。我正在使用世博会。我对本机反应非常陌生,并不真正知道我在做什么,但我知道我的代码应该可以工作。我根据他的代码仔细检查了我的代码,甚至将我的项目复制到朋友的 mac 上,看看代码是否可以在 ios 上运行(因为 mosh 正在 ios 模拟器上运行他的代码)。在ios模拟器上,我的代码运行完美,但在android上,没有任何反应。
这是我实现可滑动本身的地方:
import React from 'react';
import { StyleSheet, View, Image, TouchableHighlight } from 'react-native';
import Swipeable from 'react-native-gesture-handler/Swipeable';
import AppText from './AppText';
import colors from '../config/colors';
function ListItem({title, subtitle, image, onPress, renderRightActions}) {
return (
<Swipeable renderRightActions={renderRightActions} >
<TouchableHighlight underlayColor={colors.light} onPress={onPress} >
<View style={styles.container} >
<Image style={styles.image} source={image} />
<View>
<AppText style={styles.title} >{title}</AppText>
<AppText style={styles.subTitle}>{subtitle}</AppText>
</View>
</View>
</TouchableHighlight>
</Swipeable>
);
}
Run Code Online (Sandbox Code Playgroud)
然后我将其导出到另一个屏幕:
function MessagesScreen(props) …Run Code Online (Sandbox Code Playgroud)