【发布时间】:2018-08-27 08:28:14
【问题描述】:
我是开发 react-native 应用程序的新手,我需要在其中链接 html 文件。它在我的 android 模拟器上提供空白输出,甚至没有任何错误。我只想知道如何将 html 文件与 react native 链接。基本代码示例如下..
我已经浏览了下面的链接,但它在我的场景中不起作用.. (React Native) Load local HTML file into WebView
App.js
import React, { Component } from 'react';
import {
View,
WebView
} from 'react-native';
const DataHTML = require('./data.html');
export default class App extends Component<Props> {
render() {
return (
<View>
<WebView
source={DataHTML}
style={{flex: 1}}
/>
</View>
);
}
}
数据.html
<html>
<head></head>
<body>
<h1>Hello</h1>
</body>
</html>
【问题讨论】: