如何将屏幕快照图像保存到React Native中的电话存储



此代码成功运行,但在Android模拟器存储中没有找到屏幕截图。有什么问题?在手机存储中保存屏幕截图是否需要更改?

return (
      <View style={styles.container}>
        <Text style={styles.welcome}>
          Welcome to React Native SnapShot!
        </Text>
        <Text style={styles.instructions}>
          To get started, edit App.js
        </Text>
        <Text style={styles.instructions}>
          {instructions}
        </Text>
        <Button
          onPress={
            () => {
            captureScreen({
              format: "jpg",
              quality: 0.8
            })
            .then(
              uri => console.log("Image saved to", uri),
              error => console.error("Oops, snapshot failed", error)
            );
          }
          }
          title="capture"
          color="#841584"
          accessibilityLabel="Capture"
        />
      </View>
    );

请使用以下模块在本地存储中保存映像https://github.com/francisco-sanchez-molina/reaect-native-native-native-store-store-photos-photos-album

import CameraRollExtended from 'react-native-store-photos-album'

<Button
  onPress = {
    () => {
      captureScreen({
          format: "jpg",
          quality: 0.8
        })
        .then(
          uri => {
            CameraRollExtended.saveToCameraRoll({
              uri: uri,
              album: 'Name'
            }, 'photo')
          },
          error => console.error("Oops, snapshot failed", error)
        );
    }
  }
/>

最新更新