React-native之Alert


普通的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'
        )

  

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM