我用react-native-webview来呈现HTML文本.但在iOS中文本太小,而在android中则是完美的.

以下是几行代码:

import { WebView } from "react-native-webview";


render() {
  <WebView
        originWhitelist={['*']}
        source={{ html: '<p>This is a static HTML source!</p>' }}
  />
}

附加屏幕截图:

enter image description here

推荐答案

使用viewport meta标记控制移动浏览器上的布局

<meta name="viewport" content="width=device-width, initial-scale=1">

<WebView
      originWhitelist={['*']}
      source={{ html: '<html><head><meta name="viewport" content="width=device-width, initial-scale=1.0"></head><body><p>This is a static HTML source!</p></body></html>' }}
/>

链接:https://github.com/react-native-community/react-native-webview/issues/386

React-native相关问答推荐

Appcenter构建失败错误号::EEXIST -文件存在于syserr_fail2_in

react native :navigationOptions 中的标题样式不起作用

判断状态对象是否为空

如何清除react-native webview cookie?

使用直接在 Windows 中运行的模拟器在 WSL 中运行 React Native

如何将参数传递给graphql片段?

React native base headers for ios not found

如何将 View 定位在 ScrollView 的底部?

java.lang.ClassNotFoundException:在路径上找不到类.MainActivity:DexPathList react-native

错误:无法解析模块`buffer`

React Native ScrollView 在snapping后重新回到顶部

React-Native: measure测量一个视图

Android 构建错误AndroidManifest.xml requires a placeholder substitution

将 React Native 升级到 0.60-RC2 后找不到库libjsc.so

> 任务 :app:checkDebugAarMetadata 在运行 react-native run-android 时失败

React Native:如何将 的高度和宽度设置为 容器?

带有 React Native 的 EventEmitter 和 Subscriber ES6 语法

在 React Native ScrollView 中检测滚动结束,对齐页面

如何在android studio中导入react native元素

在 React Native 中,两个等宽的按钮水平填充屏幕