Javascript html文件未使用react native正确链接/执行
我刚开始开发react本机应用程序,需要在其中链接html文件。它在我的android仿真器上提供空白输出,甚至没有任何错误。我只是想知道如何将html文件与react native链接。下面给出了基本代码示例 我已经浏览了下面的链接,但它在我的场景中不起作用。。 App.jsJavascript html文件未使用react native正确链接/执行,javascript,react-native,Javascript,React Native,我刚开始开发react本机应用程序,需要在其中链接html文件。它在我的android仿真器上提供空白输出,甚至没有任何错误。我只是想知道如何将html文件与react native链接。下面给出了基本代码示例 我已经浏览了下面的链接,但它在我的场景中不起作用。。 App.js import React, { Component } from 'react'; import { View, WebView } from 'react-native'; const DataHTML =
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>
);
}
}
import React,{Component}来自'React';
进口{
看法
网络视图
}从“反应本机”;
const DataHTML=require('./data.html');
导出默认类应用程序扩展组件{
render(){
返回(
);
}
}
data.html
<html>
<head></head>
<body>
<h1>Hello</h1>
</body>
</html>
你好
通常,网络视图应该出现。尝试将视图和WebView的flex设置为1,或设置显式大小
<View style={{flex: 1}}>
<WebView
source={DataHTML}
style={{flex: 1}}
/>
</View>
希望这有帮助