reactjs - 标准 React Native 组件的包装器在 Web 浏览器中不起作用
问题描述
在我的 React Native / Expo 应用程序中,我为标准组件编写了一些包装器,这些包装器带有我在应用程序中经常需要的基本样式。有一个包装器Text
,它只分配标准字体系列和字体大小。这些样式也可以被覆盖。
组件:
import React from 'react';
import { Text } from 'react-native';
import { rsz } from 'shared/responsiveSize';
export const SimpleText = (props) => {
return (
<Text style={{...basicStyles, ...props.style}}>{props.children}</Text>
);
}
const basicStyles = {
fontFamily: 'lucida grande, tahoma, verdana, arial, sans-serif',
fontWeight: 'bold',
fontSize: rsz(16)
};
用法:
<SimpleText style={{fontSize: 32}}>Hello world</SimpleText>
在我的 Android 手机上的 Expo 应用程序中测试时它工作正常,但在 Google Chrome 的移动设备模拟器中,基本样式不会被组件实例的样式覆盖。模拟设备(iPhone、iPad、Google Pixel)无关紧要。
当然,网页视图只是为了测试,但由于我没有其他移动设备,我不能确定在任何其他平台上都不会出现同样的问题。
解决方案
推荐阅读
- java - WSO2 IS PostAuthnMissingClaimHandler 不工作
- elasticsearch - 弹性查询以获取缺少对应对的事件
- php - 为什么 grapheme_extract 不为“\r\n”提取任何内容?
- ssis - 如何让 SSIS 选择目录中的特定文件并将名称分配给变量(文件系统任务)
- android - 错误:“ android.view.InflateException:二进制 XML 文件第 7 行:二进制 XML 文件第 7 行:膨胀类错误
" - javascript - Axios post .then 功能会在 Chrome 中触发,但不会在 Firefox/Safari 等中触发
- python - 使用多元正态分布与 Tensorflow-probability.layers 的混合
- sql - SQL Server 2017 的安装问题(错误 1639)
- android - 如何使用 Safe Args 传递通用数据类型?
- c# - 使用 C# 在运行时更改 Web.config 文件键值而不更改文件结构