<template>
<div>
{{tableData}}
div>
template>
<script>
export default {
data () {
return {
tableData: [
{
"syncing": true,
"tokenId": 1,
"address": "0xbb0e17ef65f82ab018d8edd776e8dd940327b28b",
"chainId": 1,
"chain": {
"chainId": 1,
"chainName": "string",
"actionCode": "",
"chainDataUrl": "",
"apiUrl": "",
"apiToken": "",
"apiSecret": "",
"isDelete": false
},
"tokenName": "Axie Infinity Shard",
"symbol": "AXS",
"createTime": "2022-07-27T15:21:56.2603",
"totalSupply": 270000000,
"price": 1,
"syncVersion": 0
},
{
"syncing": false,
"tokenId": 2,
"address": "测试",
"chainId": 1,
"chain": {
"chainId": 2,
"chainName": "测试3",
"actionCode": "",
"chainDataUrl": "",
"apiUrl": "",
"apiToken": "",
"apiSecret": "",
"isDelete": false
},
"createTime": "2022-07-27T15:51:42.912249",
"syncVersion": 0
},
{
"syncing": true,
"tokenId": 6,
"address": "测试3",
"chainId": 2,
"createTime": "2022-07-28T11:51:55.256964",
"syncVersion": 0
}
]
}
},
mounted(){
this.tableData.forEach((item,index) => {
console.log(item,'itemmmm');
// console.log(item['chain'] ,'chain对象');
// console.log(item['chain'].chainName ,'chain对象下面的chainName 这样报错 看下面步骤');
// console.log(item['chain'] && item['chain'].chainName ,'chain对象下面的chainName 这样就不报错了');
console.log(item['chain'] && item['chain'].chainName ? item['chain'].chainName : '' , '这种最全面,取里面的chainName的值');
})
}
}
script>
感觉文章好的话记得点个心心和关注和收藏,有错的地方麻烦指正一下,如果需要转载,请标明出处,多谢!!!