码迷,mamicode.com
首页 > 其他好文 > 详细

React-native之Alert

时间:2016-08-18 12:54:45      阅读:224      评论:0      收藏:0      [点我收藏+]

标签:

普通的alert

先看函数原型

       alert: (title: string, message?: string, buttons?: AlertButton[], type?: string) => void

  

函数实现

        Alert.alert(
            ‘标题‘,
            ‘内容‘,
            [
                {text: ‘Ask me later‘, onPress: () => console.log(‘Ask me later pressed‘)},
                {text: ‘Cancel‘, onPress: () => console.log(‘Cancel Pressed‘), style: ‘destructive‘},
                {text: ‘OK‘, onPress: () => console.log(‘OK Pressed‘)}
            ]
        )

  

带输入框的alert-----iOS

原型

        prompt: ( title: string, value?: string, callbackOrButtons?: (value: string) => void | Array<AlertIOSButton>, type?: string, defaultValue?: string ) => void

  

实现

AlertIOS.prompt(
            ‘标题‘,
            ‘内容‘,
            (value:string)=>{
                console.log(value);
            },
            ‘plain-text‘,
            ‘default-string‘
        )

  

 

React-native之Alert

标签:

原文地址:http://www.cnblogs.com/liuShanPei1024/p/5783257.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!