属性 'opacity' 在类型 'IntrinsicAttributes' 上不存在 React native 中视图不透明度的抛出和错误
Property 'opacity' does not exist on type 'IntrinsicAttributes' throwing and error for view Opacity in React native
写完这句话后,打字稿文件在下面一行显示错误。
React-Native 0.60+
您可以传入一个新的不透明度属性:
<View opacity={true ? 0.5 : 1}> </View>
错误堆栈:错误 属性 'opacity' 在类型 'IntrinsicAttributes 和 IntrinsicClassAttributes 视图不透明度上不存在。
没有与此调用匹配的重载。重载 1 of 2,'(props: ViewProps | Readonly): View',出现以下错误。输入'{ children: Element;不透明度:布尔值; }' 不可分配给类型 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly & Readonly<{ children?: ReactNode; }>'.
属性 'opacity' 在类型 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly & Readonly<{ children?: ReactNode; }>' 上不存在。
Overload 2 of 2, '(props: ViewProps, context: any): View',出现以下错误。
输入'{ children: Element;不透明度:布尔值; }' 不可分配给类型 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly & Readonly<{ children?: ReactNode; }>'.
如何解决此警告,提前致谢。
我通过以下代码解决了这个错误:
<View style={{ opacity: true ? 0.5 : 1 }}>
编码愉快!
写完这句话后,打字稿文件在下面一行显示错误。
React-Native 0.60+ 您可以传入一个新的不透明度属性:
<View opacity={true ? 0.5 : 1}> </View>
错误堆栈:错误 属性 'opacity' 在类型 'IntrinsicAttributes 和 IntrinsicClassAttributes 视图不透明度上不存在。
没有与此调用匹配的重载。重载 1 of 2,'(props: ViewProps | Readonly): View',出现以下错误。输入'{ children: Element;不透明度:布尔值; }' 不可分配给类型 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly & Readonly<{ children?: ReactNode; }>'.
属性 'opacity' 在类型 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly & Readonly<{ children?: ReactNode; }>' 上不存在。
Overload 2 of 2, '(props: ViewProps, context: any): View',出现以下错误。 输入'{ children: Element;不透明度:布尔值; }' 不可分配给类型 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly & Readonly<{ children?: ReactNode; }>'.
如何解决此警告,提前致谢。
我通过以下代码解决了这个错误:
<View style={{ opacity: true ? 0.5 : 1 }}>
编码愉快!