问题描述
我正在使用“@react-navigation/bottom-tabs”:“^5.11.11” 并创建底部选项卡导航。但是 tintColor 不适用于 Image 组件
import React from 'react';
import { Image } from 'react-native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { createStackNavigator } from '@react-navigation/stack';
const SupportStack = createStackNavigator();
const Tab = createBottomTabNavigator();
const SPressPlusDashboard = ({ navigation }) => {
return (
<Tab.Navigator
initialRouteName={'Support'}
tabBarOptions={{
activeTintColor: '#0062C8',inactiveTintColor: '#979797',}}
>
<Tab.Screen
name='Support'
component={SupportStackScreen}
options={{
tabBarLabel: 'Support',tabBarIcon: ({ color,size }) => <Image source={Images.sPressPlusIcons.supportIcon} tintColor={color} />,}}
/>
</Tab.Navigator>
);
};
export default SPressPlusDashboard;
linting 在 tintColor
上给我这个错误:
No overload matches this call.
Overload 1 of 2,'(props: ImageProps | Readonly<ImageProps>): Image',gave the following error.
Type '{ source: any; tintColor: string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Image> & Readonly<ImageProps> & Readonly<{ children?: ReactNode; }>'.
Property 'tintColor' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Image> & Readonly<ImageProps> & Readonly<{ children?: ReactNode; }>'.
Overload 2 of 2,'(props: ImageProps,context: any): Image',gave the following error.
Type '{ source: any; tintColor: string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Image> & Readonly<ImageProps> & Readonly<{ children?: ReactNode; }>'.
Property 'tintColor' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Image> & Readonly<ImageProps> & Readonly<{ children?: ReactNode; }>'.ts(2769)
(JSX attribute) tintColor: string
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)