reactjs - undefined 不是函数(评估 'RNViewShot.captureRef(view,options)')
问题描述
我正在尝试通过 react native 在 android 中保存视图。在 Expo 中拍摄 viewshot 时,React native viewshot 在 android 中引发以下错误。这是我的代码
import React from 'react';
import { View ,Image,Button} from 'react-native';
import ViewShot from "react-native-view-shot"
import { captureRef } from "react-native-view-shot";
export default class App extends React.Component {
constructor(props){
super(props)
this.capture = this.capture.bind(this)
}
capture(){
this.refs.viewShot.capture().then(uri => {
console.log("do something with ", uri);
},(error)=>{console.log("error",error)})
}
render() {
return (
<View style={styles.container}>
<ViewShot ref="viewShot" >
<Image source={require("./batman.jpg")}>
</Image>
</ViewShot>
<Button
title="save"
onPress={this.capture}
>
</Button>
</View>
);
}
}
解决方案
推荐阅读
- machine-learning - (ResNet50, VGG16, etc..) 和 (RCNN, Faster RCNN, etc..) 有什么区别?
- python - 计算大熊猫数据帧的距离矩阵 (1664599, 3935)
- google-analytics - 如何通过 GTM 触发 GA hitType=data?
- android - 在设置 react-native-incoming-call 时,我仍然在清单文件中收到此错误
- python - Dash - 回调 - 从按钮启动脚本
- python - 将分类列转换为附加列
- html - 在 Angular 应用程序中获取选定的文本
- vue.js - 禁用 Vue devserver 中文件夹的热重载
- c++ - Qt 6.2:QMediaPlayer 和 QByteArray
- python - python 3中生日悖论的蒙特卡罗模拟