ต้องการไฟล์หรือรูปภาพแบบไดนามิกในเมธอด need

ฉันกำลังใช้ reactnative สำหรับแอปพลิเคชันมือถือ และมีปัญหาฉันมีไฟล์ json ซึ่งฉันต้องการในไฟล์ js ในไฟล์ json ยังมีเส้นทางรูปภาพมากมาย เมื่อฉันต้องการไฟล์ json จากโฟลเดอร์ในไฟล์ js ของฉัน เส้นทางจะถูกเปลี่ยนสำหรับรูปภาพนั้นซึ่งอยู่ในไฟล์ json และฉันก็ไม่สามารถส่งสตริงไดนามิกในเมธอด need ได้

นี่คือรหัสของฉันในไฟล์ JSON:

 {
  "Industry": [
    {
      "Id": "1",
      "UpperImg": "../../../uploads/bposervices/industry/Bankingimg.png",
      "FiledName": "Financial Services",
      "FileName": "FS.json",
      "Url"       :"uploads/json/FS.json"
    },
    {
      "Id": "2",
      "UpperImg": "../../../uploads/bposervices/industry/Insimg.png",
      "FiledName": "Insurance",
      "FileName": "Insurance.json",
      "Url"       :"uploads/json/Insurance.json"
    }
  ],

  "Enterprises": [
    {
      "Id": "1",
      "UpperImg": "uploads/bposervices/enterprise/Faimg.png",
      "FiledName": "Finance & Accounting",
      "FileName": "FandA.json",
      "Url"       :"uploads/json/FandA.json"
    },
    {
      "Id": "2",
      "UpperImg": "uploads/bposervices/enterprise/Spimg.png",
      "FiledName": "Sourcing & Procurement",
      "FileName": "SandP.json",
      "Url"       :"uploads/json/SandP.json"
    }
  ]
}

นี่คือไฟล์ js ของฉัน:

const abc = require('../../folder/a.json)
class B extends component {
  render() {
    return (
      <Container style={styles.container}>
        <Content>
          <List
            dataArray={abc.industry} renderRow={dataIndustry =>
              <ListItem>
                <Card>
                  <CardItem cardBody>
                    <Image source={dataIndustry.UpperImg}/>
                   // or <Image source ={require(dataIndustry.UpperImg)/> 
                  </CardItem>
                  <CardItem>
                    <Text>{dataIndustry.FiledName}</Text>
                  </CardItem>
                </Card>
              </ListItem>
            }
          />
        </Content>
      </Container>
    );
  }
}

เมื่อฉันวนซ้ำอาร์เรย์ของวัตถุของไฟล์ json ฉันจะได้รับเส้นทางรูปภาพที่ฉันส่งผ่านต้องใช้วิธี แต่มันไม่ยอมรับเส้นทางรูปภาพแบบไดนามิกในวิธีที่ต้องการทั้งในแหล่งรูปภาพ

ใครช่วยแนะนำฉันได้บ้างว่าฉันจะเหมือนกันได้อย่างไร


person Shyam Kumar    schedule 05.07.2017    source แหล่งที่มา
comment
สิ่งนี้อาจเป็นไปไม่ได้ @shyam-kumar ดูปัญหานี้ด้วย สิ่งนี้ และ สิ่งนี้   -  person Anton    schedule 05.07.2017