未定义不是函数(评估'RNViewShot.captureRef(view,options)')

时间:2018-09-16 08:29:32

标签: reactjs react-native react-native-android

我试图通过react native将视图保存在android中。在Expo拍摄快照时,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>
);
}
}

enter image description here

0 个答案:

没有答案