Expo - React Native - 如何在 expo web 中拖放图像

问题描述 投票:0回答:1

我想将图像文件拖放到我的组件中。尽管搜索了github,expo。我找不到如何做到这一点。有什么想法吗?

component

react-native drag-and-drop expo
1个回答
0
投票

我可以结合 2 个 expo 库、expo-document-picker 和 expo-drag-drop-content-view 来实现这种效果(expo 50)。

拖放组件将在onDrop事件中返回文件数据。assets作为base64编码的数据。

然后您只需将 base64 byteArray 数据转换为 URI:

const blob = new Blob([byteArray], { type: asset.type });
const uri = URL.createObjectURL(blob);

使用该 URI 的方式与使用 DocumentPicker 资产 URI 的方式完全相同。

© www.soinside.com 2019 - 2024. All rights reserved.