Button

参考文档

一个简单的跨平台的按钮组件。可以进行一些简单的定制。

这个组件的样式是固定的。所以如果它的外观并不怎么搭配你的设计,那你需要使用TouchableOpacity或是TouchableNativeFeedback组件来定制自己所需要的按钮。

查看 Props

属性 类型 必填 描述
onPress function 用户点击此按钮时所调用的处理函数
title string 按钮内显示的文本
accessibilityLabel string 用于给残障人士显示的文本(比如读屏应用可能会读取这一内容)
color color 文本的颜色(iOS),或是按钮的背景色(Android)
disabled bool 设置为 true 时此按钮将不可点击。
testID string 用来在端到端测试中定位此视图。
hasTVPreferredFocus bool (仅Apple TV)TV首选的焦点(请参阅View组件的文档)。(iOS 平台)

Example

示例

import React, { Component } from 'react';
import {  Button, } from 'react-native';
export  class pageComponent extends Component {
    onPressLearnMore=()=>{
        alert('点击了我')
    }
    render() {
        return (
            <Button
                onPress={this.onPressLearnMore}
                title="Learn More"
                color="#841584"
                accessibilityLabel="Learn more about this purple button"
            />
        );
    }
}
该文件修订时间: 2021-01-14 15:02:10

results matching ""

    No results matching ""