小编jii*_*Cho的帖子

React-native & typescript:<ImageBackground> 组件,类型“IntrinsAttributes &...”上不存在属性“children”

我很难理解为什么当我使用“react-native”中的组件时打字稿会给我这个错误<ImageBackground>消息<Image>

错误信息:

没有重载与此调用匹配。重载第 1 个(共 2 个)“(props: ImageBackgroundProps | Readonly): ImageBackground”出现以下错误。类型 '{ 子元素:元素;样式:{ 弹性:数字;justifyContent:“flex-end”;}; resizeMode:“覆盖”;来源:任何;}' 不可分配给类型“IntrinsicAttributes & IntrinsicClassAttributes & Readonly”。类型“IntrinsicAttributes & IntrinsicClassAttributes & Readonly”上不存在属性“children”。重载 2 个,共 2 个,“(props: ImageBackgroundProps, context: any): ImageBackground”,出现以下错误。类型 '{ 子元素:元素;样式:{ 弹性:数字;justifyContent:“flex-end”;}; resizeMode: "覆盖"; 来源:任何;}' 不可分配给类型“IntrinsicAttributes & IntrinsicClassAttributes & Readonly”。类型“IntrinsicAttributes & IntrinsicClassAttributes & Readonly”上不存在属性“children”。

主要源代码:

import React from "react";
import {
  ImageBackground,
  StyleSheet,
  View,
} from "react-native";

export default function WelcomeScreen() {
  return (
    <ImageBackground
      style={styles.background}
      resizeMode="cover"
      source={require("../assets/images/background.jpg")}
    >
      <View>
        <View style={styles.logginButton}></View>
        <View …
Run Code Online (Sandbox Code Playgroud)

typescript react-native

5
推荐指数
1
解决办法
3942
查看次数

标签 统计

react-native ×1

typescript ×1