首页 > 解决方案 > 使用 alert 打印文本以外的其他内容

问题描述

我是 React Native 的新手,我想知道是否可以使用 alert() 打印文本以外的其他内容,在我的情况下,我需要打印 QR 码(使用 ID)

其实我在这一点上:

async function fetchFirebaseQRCode(id) {
    const path = await firebase.storage().ref(`${id}.png`).getDownloadURL();
    alert(path);
  }

通过按下按钮,我得到了文本中的 id:

<Button
    onPress={() => fetchFirebaseQRCode(item.id)}
    title="QR Code"
    accessibilityLabel="qrcodeButton"
    color="#000000"
/>

那么问题来了,我可以在警报中打印图片/二维码吗?还是我需要使用模态?如果是这样,是否有一个我可以使用的简单模式?

谢谢

标签: reactjsreact-nativebuttonalertqr-code

解决方案


您可以使用视图。当有二维码时,将其显示在屏幕中央。如果它不存在,请将其隐藏。


推荐阅读