我使用react本机来开发一个带有onpress事件的简单Touchable亮点元素。iOS可以运行,但安卓每次加载一个函数需要几秒钟时间。我已经查找了一些可能的解决方案,如TouchableWithoutFeedback、TouchableNativeFeedback等。
我的想法是单击TouchableHighlight -> call handlePress function ->警报(‘hello world')。
这是我的密码。
import React from "react";
import { Image, TouchableHighlight, Platform, TouchableNativeFeedback, View, Text } from "react-native";
import styles from "./Styles";
// Plugin
import FastImage from "react-native-fast-image";
class BacktoTop extends React.Component {
constructor(props) {
super(props);
}
_handlePress = () => {
alert('hello world')
}
render() {
return (
<TouchableHighlight
style={ styles.container }
underlayColor={"#ffffff"}
// onPress={this.props.handlePress }
onPress={this._handlePress }>
<FastImage
source={
(Platform.OS === 'ios') ?
require("../../images/back_to_top.png")
:
{
// 6 months at least 1 view no deletion
uri: 'https://image.ibb.co/grvFS8/back_to_top.png',
priority: FastImage.priority.cacheOnly,
}
}
resizeMode={FastImage.resizeMode.cover}
style={{ width: 35, height: 35 }} />
</TouchableHighlight>
);
}
}
export default BacktoTop;非常感谢你的帮助。
发布于 2018-09-20 12:39:49
我认为在较高级别上呈现的视图组件越多,加载所需的时间就越长。
在我删除了我的一些在父母和删除onMomentumScrollEnd后,反应是改进的。
谢谢。
https://stackoverflow.com/questions/52423032
复制相似问题