创新互联React教程:iOS警告

利用一个特定的标题和消息来启动一个警告对话框。

创新互联专注为客户提供全方位的互联网综合服务,包含不限于成都网站制作、网站建设、外贸网站建设、天心网络推广、微信小程序开发、天心网络营销、天心企业策划、天心品牌公关、搜索引擎seo、人物专访、企业宣传片、企业代运营等,从售前售中售后,我们都将竭诚为您服务,您的肯定,是我们最大的嘉奖;创新互联为所有大学生创业者提供天心建站搭建服务,24小时服务热线:13518219792,官方网址:www.cdcxhl.com

提供一个可选按钮的列表。点击任何按钮触发各自的按下回调动作,并且忽略警告。在默认情况下,只有一个按钮是“OK”按钮。列表中最后一个按钮被视为“主”按钮,它被用粗体显示出来了。

    AlertIOS.alert(      'Foo Title',      'My Alert Msg',
      [
        {text: 'Foo', onPress: () => console.log('Foo Pressed!')},
        {text: 'Bar', onPress: () => console.log('Bar Pressed!')},
      ]
    )}

方法

static alert(title: string, message?: string, buttons?: Array<{ text: ?string; onPress: ?Function; }>)

例子

Edit on GitHub

    'use strict';    var React = require('react-native');    var {
      StyleSheet,
      View,
      Text,
      TouchableHighlight,
      AlertIOS,
    } = React;
    exports.framework = 'React';
    exports.title = 'AlertIOS';
    exports.description = 'iOS alerts and action sheets';
    exports.examples = [{      title: 'Alerts',
      render() {        return (
          
             AlertIOS.alert(                'Foo Title',                'My Alert Msg'
              )}>
              
                Alert with message and default button
              
            
             AlertIOS.alert(                null,                null,
                [
                  {text: 'Button', onPress: () => console.log('Button Pressed!')},
                ]
              )}>
              
                Alert with only one button
              
            
             AlertIOS.alert(                'Foo Title',                'My Alert Msg',
                [
                  {text: 'Foo', onPress: () => console.log('Foo Pressed!')},
                  {text: 'Bar', onPress: () => console.log('Bar Pressed!')},
                ]
              )}>
              
                Alert with two buttons
              
            
             AlertIOS.alert(                'Foo Title',                null,
                [
                  {text: 'Foo', onPress: () => console.log('Foo Pressed!')},
                  {text: 'Bar', onPress: () => console.log('Bar Pressed!')},
                  {text: 'Baz', onPress: () => console.log('Baz Pressed!')},
                ]
              )}>
              
                Alert with 3 buttons
              
            
             AlertIOS.alert(                'Foo Title',                'My Alert Msg',                '..............'.split('').map((dot, index) => ({                  text: 'Button ' + index,                  onPress: () => console.log('Pressed ' + index)
                }))
              )}>
              
                Alert with too many buttons
              
            
          
        );
      },
    }];    var styles = StyleSheet.create({      wrapper: {        borderRadius: 5,        marginBottom: 5,
      },      button: {        backgroundColor: '#eeeeee',        padding: 10,
      },
    });

本文题目:创新互联React教程:iOS警告
标题来源:http://www.hantingmc.com/qtweb/news37/147587.html

网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联