我正在使用NativeBase.io 编程React Native应用程序
在我使用NativeBase的应用程序中,我收到以下错误。。。。。我该怎么解决这个问题?
错误如下:
WARN NativeBase:上darkText的对比度为1:1透明度低于WCAG推荐的绝对最小对比度比例为3:1。https://www.w3.org/TR/2008/REC-WCAG20-20081211/#visual-音频对比度InputBase@http://localhost:8081/index.bundle?平台=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.natur.example.DanceConnect多维数据集:193716:28RCTView视图@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.natur.example.DanceConnect多维数据集:150602:25Box@http://localhost:8081/index.bundle?平台=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.natur.example.DanceConnect多维数据集:191721:24InputAdvance@http://localhost:8081/index.bundle?平台=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.naturt.example.DanceConnect立方:193858:33Input@http://localhost:8081/index.bundle?平台=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.natur.example.DanceConnect多维数据集:193651:24RCTView视图@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.natur.example.DanceConnect多维数据集:150602:25Box@http://localhost:8081/index.bundle?平台=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.natur.example.DanceConnect多维数据集:191721:24UserListScreen@http://localhost:8081/index.bundle?平台=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.natur.example.DanceConnect多维数据集:223372:50StaticContainer@http://localhost:8081/index.bundle?平台=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.natur.example.DanceConnect多维数据集:234421:17EnsureSingleNavigator@http://localhost:8081/index.bundle?平台=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.natur.example.DanceConnect多维数据集:230142:24SceneView@http://localhost:8081/index.bundle?平台=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.natur.example.DanceConnect多维数据集:234305:22RCTView视图Background@http://localhost:8081/index.bundle?平台=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.natur.example.DanceConnect多维数据集:236500:21Screen@http://localhost:8081/index.bundle?平台=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.natur.example.DanceConnect多维数据集:237782:108RNS屏幕AnimatedComponent@http://localhost:8081/index.bundle?平台=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.natur.example.DanceConnect多维数据集:67782:80动画组件包装Screen@http://localhost:8081/index.bundle?平台=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.naturt.example.DanceConnect YouTube:238098:36MaybeScreen@http://localhost:8081/index.bundle?平台=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.natur.example.DanceConnect多维数据集:237954:24RNSScree容器ScreenContainer@http://localhost:8081/index.bundle?平台=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.natur.example.DanceConnect多维数据集:238211:31MaybeScreenContainer@http://localhost:8081/index.bundle?平台=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.natur.example.DanceConnect多维数据集:237923:23RCTView视图SafeAreaProviderCompat@http://localhost:8081/index.bundle?平台=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.natur.example.DanceConnect多维数据集:237712:24BottomTabView@http://localhost:8081/index.bundle?平台=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.naturt.example.DanceConnect YouTube:226059:30@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.natur.example.DanceConnect多维数据集:234075:24BottomTabNavigator@http://localhost:8081/index.bundle?平台=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.natur.example.DanceConnect多维数据集:225921:32EnsureSingleNavigator@http://localhost:8081/index.bundle?平台=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.natur.example.DanceConnect多维数据集:230142:24BaseNavigationContainer@http://localhost:8081/index.bundle?平台=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.natur.example.DanceConnect多维数据集:229651:28ThemeProvider@http://localhost:8081/index.bundle?平台=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.natur.example.DanceConnect多维数据集:235690:21NavigationContainerInner@http://localhost:8081/index.bundle?平台=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.natur.example.DanceConnect多维数据集:235550:26SSRProvider@http://localhost:8081/index.bundle?平台=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.naturt.example.DanceConnect YouTube:193075:25ToastProvider@http://localhost:8081/index.bundle?平台=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.natur.example.DanceConnect多维数据集:204142:24PortalProvider@http://localhost:8081/index.bundle?平台=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.natur.example.DanceConnect多维数据集:201313:50HybridProvider@http://localhost:8081/index.bundle?平台=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.natur.example.DanceConnect多维数据集:214396:24RNC安全区域提供商SafeAreaProvider@http://localhost:8081/index.bundle?平台=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.naturt.example.DanceConnect YouTube:154679:24NativeBaseConfigProviderProvider@http://localhost:8081/index.bundle?平台=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.natur.example.DanceConnect多维数据集:148509:27ThemeProvider@http://localhost:8081/index.bundle?平台=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.natur.example.DanceConnect多维数据集:145479:38NativeBaseProvider@http://localhost:8081/index.bundle?平台=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.natur.example.DanceConnect多维数据集:214282:33Provider@http://localhost:8081/index.bundle?平台=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.natur.example.DanceConnect多维数据集:216267:21App@http://localhost:8081/index.bundle?平台=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.natur.example.DanceConnect多维数据集:108372:54RCTView视图AppContainer@http://localhost:8081/index.bundle?平台=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.naturt.example.DanceConnect YouTube:75251:36DanceConnect多维数据集(根组件)@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=真&app=org.reactjs.natur.example.DanceConnect多维数据集:82468:28未定义
我也收到了同样的警告。我在组件中尝试了一些颜色更改,发现问题是输入bg color是white
,而且我的视图背景是"light.100"
。我把颜色改为"transparent"
或"muted.500"
,警告消失了。此警告使我们能够更好地管理深色模式的颜色。
如果您遵循设计师的设计,并且无法更改该颜色,则可以使用LogBox跳过警告。
在index.js
文件中添加以下行
import {LogBox} from 'react-native';
LogBox.ignoreLogs(['NativeBase:']);
在我的案例中,问题是使用variant="outline"
道具来获得一个轮廓按钮。改变颜色或配色方案对我不起作用。使用borderWidth: 1
作为样式道具,错误消失了。
我用一个大纲按钮遇到了这个问题。警告";在透明上的darkText的对比度为1:1";是指按钮的背景颜色。
这是一个白上黑下亮的轮廓按钮,可在亮模式和暗模式下工作,无需硬编码颜色值(黑白除外):
import { useContrastText } from 'native-base';
const bgLight = "white";
const bgDark = "black";
const lightContrastColor = useContrastText(bgLight);
const darkContrastColor = useContrastText(bgDark);
<Button
variant="outline"
colorScheme="light"
_light={{ bg: bgLight, borderColor: lightContrastColor, _text: { color: lightContrastColor } }}
_dark={{ bg: bgDark, borderColor: darkContrastColor, _text: { color: darkContrastColor } }}
onPress={() => null}>Lorem Ipsum</Button>