我能夠從我在 RN 創(chuàng)建的本地 JSON 文件中動態(tài)引入數(shù)據(jù)。但是,當(dāng)我返回并為每個配置文件插入一個圖像以便它可以與其配置文件信息一起動態(tài)顯示時,該應(yīng)用程序中斷說“該組件不能包含子項。如果您想在圖像頂部呈現(xiàn)內(nèi)容,請考慮使用”。我已經(jīng)為所有配置文件使用了背景,所以我真的不明白它在說什么,因為我在 JSON 文件中輸入的圖像將是每個字符的配置文件圖像。我什至遵循正確的格式來調(diào)用圖像嗎?任何幫助,將不勝感激。這就是我設(shè)置 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" }}
嘗試從本地 JSON 文件調(diào)用圖像時不會加載圖像
哈士奇WWW
2021-09-30 14:59:39