我能够从我在 RN 创建的本地 JSON 文件中动态引入数据。但是,当我返回并为每个配置文件插入一个图像以便它可以与其配置文件信息一起动态显示时,该应用程序中断说“该组件不能包含子项。如果您想在图像顶部呈现内容,请考虑使用”。我已经为所有配置文件使用了背景,所以我真的不明白它在说什么,因为我在 JSON 文件中输入的图像将是每个字符的配置文件图像。我什至遵循正确的格式来调用图像吗?任何帮助,将不胜感激。这就是我设置 JSON 文件的方式: const characters = [ { id: "1", name: "Homer Simpson", occupation: "Nuclear Safety Inspector", url: "https://assets.fxnetworks.com/cms/prod/shows/the-simpsons/photos/simpsons-sidebar/character-facts/Homer/swsb_character_fact_homer_288x763.png" }, { id: "2", name: "Marge Simpson", occupation: "Stay-at-home mom", url: "https://assets.fxnetworks.com/cms/prod/shows/the-simpsons/photos/simpsons-sidebar/character-facts/Homer/swsb_character_fact_homer_288x763.png"}, { id: "3", name: "Bart Simpson", occupation: "Student", url: "https://assets.fxnetworks.com/cms/prod/shows/the-simpsons/photos/simpsons-sidebar/character-facts/Homer/swsb_character_fact_homer_288x763.png" }, { id: "4", name: "Lisa Simpson", occupation: "Student", url: "https://assets.fxnetworks.com/cms/prod/shows/the-simpsons/photos/simpsons-sidebar/character-facts/Homer/swsb_character_fact_homer_288x763.png" }, { id: "5", name: "Maggie Simpson", occupation: "Baby", url: "https://assets.fxnetworks.com/cms/prod/shows/the-simpsons/photos/simpsons-sidebar/character-facts/Homer/swsb_character_fact_homer_288x763.png" } export default characters;这就是我引入它的方式:import React from "react";import { View, Text, StyleSheet, Image, Button, ImageBackground} from "react-native";class CharacterProfiles extends React.Component { static navigationOptions = { title: "The Simpsons", headerStyle: { backgroundColor: "#53b4e6" }, headerTintColor: "#f6c945", headerTitleStyle: { fontWeight: "bold" }}
添加回答
举报
0/150
提交
取消