React-native之Alert

普通的alert

先看函數原型swift

       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

原型blog

        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'
        )
相關文章
相關標籤/搜索