React-native之Alert

react

先看函数原型

       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 的全部内容, 来源链接: utcz.com/z/382187.html

回到顶部