javascript - html 文件未与 react-native 正确链接/执行
问题描述
我是开发 react-native 应用程序的新手,我需要在其中链接 html 文件。它在我的 android 模拟器上提供空白输出,甚至没有任何错误。我只想知道如何将 html 文件与 react native 链接。基本代码示例如下..
我已经浏览了下面的链接,但它在我的场景中不起作用.. (React Native)将本地 HTML 文件加载到 WebView
应用程序.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>
解决方案
通常应该出现 WebView。尝试将 View 和 WebView 的 flex 设置为 1 或设置显式大小。
<View style={{flex: 1}}>
<WebView
source={DataHTML}
style={{flex: 1}}
/>
</View>
希望这可以帮助 !
推荐阅读
- haskell - Data.Vector 的 unsafeFreeze/unsafeThaw 到底有多“不安全”?
- azure - Azure VM 通过 powershell 的 Powerstate
- python - plotly dash,带有 2 个按钮输入和一个下拉输入的回调
- spring-boot - Jackson ObjectMapper 忽略 JsonInclude.Include.NON_NULL
- node.js - 根据子文档日期查找即将发布的文档
- c# - 如何使用 lambda 参数创建方法?
- javascript - Mongodb查询:在嵌套数组中搜索正则表达式
- json - play-json 写入是否支持索引路径?
- google-maps - 如何在颤动的谷歌地图自定义标记中添加额外的文本?
- reactjs - react-select 阻止菜单打开 onInputChange