【发布时间】:2019-07-16 06:17:48
【问题描述】:
我的问题
当我将按钮样式位置更改为绝对位置时 按钮上半部分显示按钮点击效果,但navigation('Login')功能不起作用 但是按钮的下半部分可以正常工作。
预期行为
当按钮样式的位置是绝对的时, 我希望按钮在我按下的任何地方都能正常工作。
代码示例
import React, { Component } from 'react';
import { Button } from 'react-native-elements';
import { StyleSheet, Text, View } from 'react-native';
<View style={styles.grade_view}>
<Text style={styles.grade_text}>aaaa</Text>
<Text style={styles.grade_num}>-</Text>
<Button
onPress={() => {
navigate('Login');
}}
buttonStyle={{
backgroundColor: '#AAA',
width: 140,
height: 40,
position: 'absolute',
borderRadius: 20,
top: -45,
right: 10
}}
type="solid"
title="login"
color="#AAA"
/>
</View>
const styles = StyleSheet.create({
grade_view: {
padding: 15,
borderColor: '#999',
borderBottomWidth: 1
},
grade_num: {
marginTop: 5,
fontSize: 26,
fontWeight: 'bold',
},
grade_text: {
fontSize: 16,
color: '#AAA'
}
});
环境
react-native-cli: 2.0.1
反应原生:0.58.4
节点:v10.15.0
npm:6.4.1
测试设备:iPhone X - 12.1(XCode 虚拟设备)
React Native 环境信息:
系统:
操作系统:macOS 10.14.2
CPU:(4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
内存:34.14 MB / 8.00 GB
外壳:3.2.57 - /bin/bash
二进制文件:
节点:10.15.0 - /usr/local/bin/node
npm: 6.4.1 - /usr/local/bin/npm
SDK:
iOS SDK:
平台:iOS 12.1、macOS 10.14、tvOS 12.1、watchOS 5.1
IDE:
Android Studio:3.2 AI-181.5540.7.32.5056338
Xcode:10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
反应:^16.6.3 => 16.6.3
反应原生:0.58.4 => 0.58.4
npmGlobalPackages:
react-native-cli: 2.0.1
【问题讨论】:
-
当您使用位于其父组件之外的按钮时,这是 Android 上的一个已知错误。在 iOS 上它可以工作。您需要找到解决方法。
-
我在 iPhone X - 12.1 Simulator 上测试过。
-
在安卓上完美运行。
标签: react-native