未定义的数组元素---无法解释

时间:2018-10-10 01:28:57

标签: arrays json react-native

具有相似结构和相同数组对象元素的图像url返回一个有效,而另一个返回undefined。两个元素(image和image1)的控制台日志都确认了这种奇怪的行为。请查看Firebase数据(位置),渲染代码段和控制台输出。这解释了为什么尝试使用与image1完全相似的image标签渲染image1会返回undefined的原因。 请注意,从后端数据返回的所有道具均正确渲染,但后续的图像元素(image1)除外。对如何获得第二个图像链接感到困惑和困惑。 json数据示例:

"places": [{

        "id": "a",
        "image": "https://res.cloudinary.com/obisi7/image/upload/v1537575323/tourNaija/slave/slavePic.jpg",
        "title": "Slave Trade Museum",
        "description": "Excerpts from Freeman Institute",
        "subTitle": "One of many rare gems of history and education",
        "location": "Jos, Lagos, Calabar, Abuja, etc",
        "phone": "212-555-7890",
        "credit": "The Freeman Institute",
        "image1": "https://res.cloudinary.com/obisi7/image/upload/v1537575322/tourNaija/slave/abolitionCannon.jpg",
        "image2": "https://res.cloudinary.com/obisi7/image/upload/v1537575322/tourNaija/slave/holdingCell.jpg",
        "image3": "https://res.cloudinary.com/obisi7/image/upload/v1537575322/tourNaija/slave/slaveMarket.jpg",
        "image4": "https://res.cloudinary.com/obisi7/image/upload/v1537575323/tourNaija/slave/slaveNoReturn.jpg",
        "image5": "https://res.cloudinary.com/obisi7/image/upload/v1537575323/tourNaija/slave/bibleAtBadagry.jpg",
        "image6": "https://res.cloudinary.com/obisi7/image/upload/v1537575322/tourNaija/slave/bridge.jpg"
    },

用于渲染图像和image1等的代码段

render() {
const { showModal, articleData, } = this.props;
const { image, image1, title, subTitle, description,location, phone, credit,  } = articleData;

console.log(image);
console.log(image1);

        <View>


      {/* Below segment used to display place photos for tapped site. Not working yet */}
        {
              <TouchableOpacity  >
                <Image  
                    source={{ uri: image1} } 
                    style={styles.navImageStyle}
                />

              </TouchableOpacity>
        }

Console.log:

debugger window screenshot

0 个答案:

没有答案