如何在react-native中获取位于根目录中的文件路径

时间:2017-02-01 23:46:09

标签: android reactjs mobile react-native

我想在react-native应用程序中显示一个图表,为此我需要使用Webview组件呈现我在根目录中的文件夹中的html文件。我之前已经为IOS完成了此操作,我使用react-native-fs来获取文件的路径,但我在尝试为Android执行相同操作时遇到了麻烦。

这就是我试图获取文件路径的方式:

this.chartSource = 'file://' + RNFS.DocumentDirectoryPath + '/web/chart.html';

然后我尝试渲染它:

     <WebView
      source={{uri: this.chartSource}}
      style={{marginTop: 20}}
     />

这是错误消息:

Encountered an error loading page ...
"net::ERR_FILE_NOT_FOUND","loading":false,
"title":"","url":"file://data/data/com.therapyhelper/files/chart.html","target":32}

0 个答案:

没有答案
相关问题