首页 > 解决方案 > Webview 以文本形式打开本地 html 文件

问题描述

如何使用 webview 打开本地 HTML 文件?我试图在项目的根目录中创建一个 HTML 文件并像这样添加它:

const indexHTML = require('./index.html');

const App = () => {
  return (
    <WebView
      originWhitelist={['*']}
      style={{flex: 1}}
      source={indexHTML}
    />
  );
};

但是 webview 将其作为文本文件打开。对不起我的语法不好。

标签: react-nativewebviewjsx

解决方案


推荐阅读