我已经设置了一个功能,可以在按下按钮时导航并将数据传递到另一个屏幕。问题是当我尝试发送它在控制台中显示为未定义的特定值时。但是当我尝试其他值时,它会正确通过。以下是我的代码
<FlatList data={serviceTData.tasks || []}
renderItem= {({item}) => (
<View>
<TouchableOpacity style={styles.actionButton}
onPress={() => startTT(item.id ,item.serialNumber, item.ttId, item.model)}>
<View style={styles.textContainer1}>
<Text style={styles.buttonText}>{item?.product ??''}</Text>
<Text style={styles.buttonText2}>{item?.model ?? ''}</Text>
<Text style={styles.buttonText1}>{item?.serialNumber ?? ''}</Text>
</View>
</TouchableOpacity>
</View>
)}
keyExtractor={(item) => item.ttid} />
</View>
按下功能
function startTT(serialNumber, ttID, id, model) {
console.log("startJob Serial", serialNumber)
navigation.navigate('SerialNo', { PSerial: serialNumber, ttId: ttID, STId: id, dataOBJ: serviceTData })
}
我的数据对象
Object {
"actionTime": null,
"arrivedAt": null,
"callPerson": null,
"category": null,
"contactNo": "0",
"createdAt": "2021-08-06 13:27:55",
"custName1": null,
"custName2": null,
"geoLocation": null,
"id": 1,
"location": null,
"remark": null,
"repeat": null,
"tasks": Array [
Object {
"completed": false,
"createdAt": null,
"model": "Lexmark:MS510DN",
"product": "PRINTER",
"remark": "paper jam",
"serialNumber": "451444HH1N1GT",
"status": null,
"topic": "21080295T210",
"ttId": 27226,
"warrantyStatus": "MAINTENANCE_COMPREHENSIVE",
},
],
"topic": null,
"visitingAdd1": "J/ HARTLEY COLLEGE,",
}
我可以传递该model值,但是当我尝试发送它时,serialNumber它显示为未定义。有什么特别的原因吗?