解决 RN 为TextView设置fontWeight后出现的吞字问题
在入口文件,如App.tsx添加如下代码:
import { Platform, StyleSheet, Text } from 'react-native'
...
// 解决 Android 部分机型吞字问题
const defaultFontFamily = {
...Platform.select({
android: { fontFamily: "" },
}),
}
const __render = Text.render
Text.render = function (props, ref) {
if (Platform.OS === "ios") {
return __render.call(this, props, ref)
}
const { style, ..._props } = props
const _style = StyleSheet.flatten(style) || {}
return __render.call(
this,
{ ..._props, style: { ...defaultFontFamily, ..._style } },
ref
)
}