全文未显示在反应本机的警报对话框中
Full text is not showing in alert dialog in react native
我试图在点击 button
时向用户显示 alert dialog
。我正在尝试如下
onPressButton() {
Alert.alert(strings.tour_end);
}
strings.tour_end 是 "Great! Hope you like our product tour! Enjoy this app. We have some excited offers for you!"
这是 alert
中的显示方式。这是 react-native
中的错误吗?
根据警报 API,您已将完整消息作为警报标题传递。
alert(title, message?, buttons?, options?, type?)
喜欢下面
alert("Great..!", strings.tour_end);
所以标题应该是小消息,你可以在消息参数中显示完整的消息。
如果你想开发定制的 Alert 然后使用 Modal API。 Check it.
或
您可以使用一些第三方 npm 模块来显示自定义警报。这也是基于模态 api.
npm install react-native-modalbox@latest --save
试试这个。
如果您只传递文本,它将被视为标题
根据文档 https://facebook.github.io/react-native/docs/alert..
你可以像这样传递值。
Alert.alert(
'Alert Title',
'My Alert Msg',
[
{text: 'Ask me later', onPress: () => console.log('Ask me later pressed')},
{text: 'Cancel', onPress: () => console.log('Cancel Pressed'), style: 'cancel'},
{text: 'OK', onPress: () => console.log('OK Pressed')},
],
{ cancelable: false }
)
我试图在点击 button
时向用户显示 alert dialog
。我正在尝试如下
onPressButton() {
Alert.alert(strings.tour_end);
}
strings.tour_end 是 "Great! Hope you like our product tour! Enjoy this app. We have some excited offers for you!"
这是 alert
中的显示方式。这是 react-native
中的错误吗?
根据警报 API,您已将完整消息作为警报标题传递。
alert(title, message?, buttons?, options?, type?)
喜欢下面
alert("Great..!", strings.tour_end);
所以标题应该是小消息,你可以在消息参数中显示完整的消息。
如果你想开发定制的 Alert 然后使用 Modal API。 Check it.
或
您可以使用一些第三方 npm 模块来显示自定义警报。这也是基于模态 api.
npm install react-native-modalbox@latest --save
试试这个。
如果您只传递文本,它将被视为标题
根据文档 https://facebook.github.io/react-native/docs/alert.. 你可以像这样传递值。
Alert.alert(
'Alert Title',
'My Alert Msg',
[
{text: 'Ask me later', onPress: () => console.log('Ask me later pressed')},
{text: 'Cancel', onPress: () => console.log('Cancel Pressed'), style: 'cancel'},
{text: 'OK', onPress: () => console.log('OK Pressed')},
],
{ cancelable: false }
)