如何在ReactNative中截图.我需要一个截图,把它放在Image个组件中.我该怎么办?

推荐答案

有一个图书馆可以做到这一点:React Native View Shot

import RNViewShot from "react-native-view-shot";

RNViewShot.takeSnapshot(viewRef, {
  format: "jpeg",
  quality: 0.8
})
.then(
  uri => console.log("Image saved to", uri),
  error => console.error("Oops, snapshot failed", error)
);

React-native相关问答推荐

在原生react 中更改图像源URI时闪烁

'无法解析模块.安装react-native-pager-view后的实用程序/平台

如何在使用嵌套的堆栈导航器在选项卡之间导航后弹出到堆栈顶部?

使用react-native-reanimatedreact 导航崩溃

一旦我关闭应用程序,Json struct 就会发生变化

如何将谷歌反向地理编码与 React Native Expo 结合使用?

React Native 获取视图相对于屏幕的绝对位置

如何在 Crashlytics (Fabrics) 中有效地对非致命异常进行分组?

使用 Hooks 在功能组件中react-navigation 标题

submit提交后如何让 React Native TextInput 保持焦点?

如何在 React Native 的 Modal 组件上禁用Swipe down to close?

React Native 有全局作用scope域吗?如果没有,我该如何模仿它?

redux saga 的delay延迟功能不起作用

我可以在 react-native 中使用 reactJS 库吗?

react-native Bottom Up drawer

react-native如何禁用android开发模式

在 navigator pop 上react Native Pass 属性

React-Native 元素卡在 :app:installDebug

React Context:TypeError:render is not a function

在 React Native 中将props传递给外部样式表?