Я использую react-native-view-pdf
, React Native - 0.59.5
https://github.com/rumax/react-native-PDFView
Я просто следую учебному пособию, но показываю пустой экран.Я не могу понять это.Я не знаю, почему они показывают пустые экраны.
Шаг 1:
npm install react-native-view-pdf --save
Шаг 2:
react-native link react-native-view-pdf
Используйте код и введите react-native run-ios
App.js:
import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View} from 'react-native';
import PDFView from 'react-native-view-pdf/lib/index';
const instructions = Platform.select({
ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu',
android:
'Double tap R on your keyboard to reload,\n' +
'Shake or press menu button for dev menu',
});
const resources = {
file: Platform.OS === 'ios' ? 'downloadedDocument.pdf' : '/sdcard/Download/downloadedDocument.pdf',
url: 'https://www.ets.org/Media/Tests/TOEFL/pdf/SampleQuestions.pdf',
base64: 'JVBERi0xLjMKJcfs...',
};
type Props = {};
export default class App extends Component<Props> {
render() {
const resourceType = 'url';
return (
<View style={styles.container}>
<Text style={styles.welcome}>Welcome to React Native!</Text>
<PDFView
fadeInDuration={250.0}
style={{ flex: 1 }}
resource={'https://www.ets.org/Media/Tests/TOEFL/pdf/SampleQuestions.pdf'}
resourceType={resourceType}
onLoad={(event) => console.log(`PDF rendered from ${event}`)}
onError={(error) => console.log('Cannot render PDF', error)}
/>
<Text>Bottom text</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
Показать черный экран: