react-native-webview无法从react-native中的URL加载文档(pdf,doc,xls)

时间:2019-07-25 07:32:42

标签: react-native react-native-webview

我正在使用react-native应用程序,在其中使用pdf, doc/docx, xls,/xlsx在应用程序内显示上载文档(react-native-webview),如下所示,

<WebView
    source={{ uri: 'DOCUMENT_LINK' }} 
    onLoadStart={syntheticEvent => {
                                    // update component to be aware of loading status
                                    const { nativeEvent } = syntheticEvent;
                                    console.log('LStart :' + JSON.stringify(nativeEvent));
                                }
    }
    onLoadEnd={syntheticEvent => {
                                         // update component to be aware of loading status
                                        const { nativeEvent } = syntheticEvent;
                                        console.log('LEnd:' + JSON.stringify(nativeEvent));
                                    }}
    />

现在这里有时是从URL加载文档,但有时会引发错误(10次中有2次),如下所示:

LStart :{"canGoForward":false,"canGoBack":false,"title":"about:blank","loading":true,"url":"about:blank","target":3265}    
LEnd :{"canGoForward":false,"canGoBack":false,"title":"about:blank","loading":false,"url":"about:blank","target":3265}

我不知道这是怎么回事。任何人都可以有任何想法。

0 个答案:

没有答案