添加第三方截屏库 npm install react-native-view-shot
import ViewShot from "react-native-view-shot"
class ExampleCaptureScrollViewContent extends Component {
render() {
return (
<ScrollView>
//截取ViewShot中内容
<ViewShot ref="viewShot">
<Text>...</Text>
<Text>...</Text>
<Text>...</Text>
...
</ViewShot>
<TouchableOpacity
onPress={() => this.refs.viewShot.capture().then(uri => {
console.log(uri)
})}>
<Text>截屏</Text>
</TouchableOpacity>
</ScrollView>
);
}
}