相关疑难解决方法(0)

React Native,TouchableOpacity包装浮动按钮什么都没得到

我正在创建一个简单的动作按钮(浮动按钮)

这是有效的:

<View style={{
    width: this.props.size,
    height: this.props.size,
    borderRadius: this.props.size / 2,
    backgroundColor: '#ee6e73',
    position: 'absolute',
    bottom: 10,
    right: 10,
    flexDirection:'row'
}}>
    <Text>
        +
    </Text>
</View>
Run Code Online (Sandbox Code Playgroud)

这不是 :

<TouchableOpacity
        onPress={()=>{
        }} >
    <View style={{
        width: this.props.size,
        height: this.props.size,
        borderRadius: this.props.size / 2,
        backgroundColor: '#ee6e73',
        position: 'absolute',
        bottom: 10,
        right: 10,
        flexDirection:'row'
    }}>
        <Text>
            +
        </Text>
    </View>
</TouchableOpacity>
Run Code Online (Sandbox Code Playgroud)

只需使用TouchableOpacity包装,然后我的按钮就不会出现任何错误.

React 0.1.7,Android

然后我尝试从View到TouchableOpacity移动样式,这是工作

<TouchableOpacity
        onPress={()=>{
        }} 
        style={{
            width: this.props.size,
            height: this.props.size,
            position: 'absolute',
            borderRadius: this.props.size / 2,
            backgroundColor: '#ee6e73',
            bottom: 10,
            right: …
Run Code Online (Sandbox Code Playgroud)

android floating-action-button react-native

5
推荐指数
2
解决办法
8151
查看次数