React Native WebView for Android不显示PDF和Word文件

问题描述 投票:0回答:1

我正在开发有关发布个人简历的新项目。

我需要在应用程序中显示用户的简历。

下面是我的标准WebView代码,在iOS上运行良好。

import * as React from 'react';
import { WebView } from 'react-native';


export default class App extends React.Component {
  render() {
    return (
      <WebView
            style={{flex: 1, backgroundColor: 'white'}}
            source={{
              uri: 'http://www.africau.edu/images/default/sample.pdf',
            }}
            bounces={true}
            useWebKit={true}
            scrollEnabled={true}
          />
    );
  }
}

此代码也需要在Android上运行。当我在Android上尝试时,页面什么都没有显示。

You can try this on Expo Snack.

react-native webview react-native-webview
1个回答
1
投票

Android Webview无法显示PDF文件。存在与此问题有关的问题。您可以从this link

查看

您的问题有多种解决方案,您可以自己选择最相关的一种。

1)使用react-native-pdf-view

2)使用Google文档作为查看器。尝试在您的Webview http://docs.google.com/gview?embedded=true&url=http://www.africau.edu/images/default/sample.pdf

中加载此URL

3)Use Chrome Custom Tabs

© www.soinside.com 2019 - 2024. All rights reserved.