在ReactJS中访问数组中的对象

时间:2016-07-22 10:49:44

标签: javascript arrays json reactjs

我目前在使用React解析一些JSON数据时遇到问题。这是我想要使用的JSON数据:

class TestWrapper():
    def __init__(self, a, b):
        self.a = a
        self.b = b
        self.c = 0

    def enter_exit_info(func):
        def wrapper(self, *arg, **kw):
            print '-- entering', func.__name__
            print '-- ', self.__dict__
            res = func(self, *arg, **kw)
            print '-- exiting', func.__name__
            print '-- ', self.__dict__
            return res
        return wrapper

    @enter_exit_info
    def add_in_c(self):
        self.c = self.a + self.b
        print self.c

    @enter_exit_info
    def mult_in_c(self):
        self.c = self.a * self.b
        print self.c


if __name__ == '__main__':
    t = TestWrapper(2, 3)
    t.add_in_c()
    t.mult_in_c()

我可以使用大部分数据但是当我尝试访问[ { "id": 3, "car_brand_id": 2, "car_model_id": 7, "youtube": "", "title": "New Ibiza range available in Sunderland & Durham - Pulman SEAT ", "description": "Buy a new Ibiza from Pulman SEAT - Available to test drive in Sunderland & Durham", "slug": "ibiza", "published": 1, "news": 0, "published_at": "2016-07-05 09:16:04", "created_at": "2016-05-23 12:45:20", "updated_at": "2016-07-05 13:16:04", "offers": [ { "id": 9, "car_page_id": 3, "car_trim_id": 15, "car_type_id": 1, "cap_code_id": 0, "car_image_id": 70, "derivative": "SC 1.2 TSI 90PS ", "car_position_id": 6, "youtube_code": "XDKSBXbIXV0", "terms": "This offer is for the from Pulman SEAT is based on PCP (personal contract plan). Valid for retail customers only. Vehicles to be registered and delivered before 30/09/16. Offer can be withdrawn at any time. It can also be extended. No other offers may be used in conjunction with the above detailed offer. At the beginning of the plan SEAT Financial services is the legal owner and provider of this PCP. At the end of the agreement there are 3 options: (i) Renew: Part exchange the vehicle (ii) Retain: Pay the Optional Final Payment to own the vehicle or (iii) Return the vehicle. *Payable with first payment. ** Payable with optional final payment. #4.4p per mile excess mileage charges apply. Further charges may be payable if vehicle is returned. Indemnities may be required. Subject to status. Available to over 18s in the UK only. Offer is subject to vehicle availability and may be varied or withdrawn at any time. Certain vehicles excluded- ask for full details. Finance providers may pay us for introducing you to them. We can introduce you to a limited number of lenders to assist with your purchase, who may pay us for introducing you to them. † £2,500 deposit contribution available on Ibiza SC FR 1.2 TSI 90PS when purchased on SEAT Solutions. ^ £671 Saving based on RRP. Images for illustration purposes only. ^^ One year’s insurance included at no extra cost from SEAT Insurance is available on all qualifying new Ibiza FR models only ordered from 1st July 2016 to 30th September 2016 and registered by 10th January 2017 for drivers 18 and over. Drivers under 18 are not eligible. May exclude Northern Ireland. Drivers aged 18-24 are required to share their driving style data with a telematics product. Available on Ibiza FR trim only. Other eligibility criteria apply. Go to www.seat.co.uk/free-insurance-offer for full terms and conditions. This offer may be extended, changed or removed at any point. SEAT Motor Insurance from SEAT Financial Services is arranged and administered by Carrot Risk Technologies Limited.", "status": 1, "created_at": "2016-07-04 15:08:03", "updated_at": "2016-07-19 14:03:46", "image": { "id": 70, "car_image_category_id": 7, "image_name": "Ibiza-FR-SC-Insurance", "name": "aa093fb987a0898588daa8825f90001443afc68d.png", "path": "img/imagedb/aa093fb987a0898588daa8825f90001443afc68d.png", "thumbnail_path": "img/imagedb/thumbs/tn-aa093fb987a0898588daa8825f90001443afc68d.png", "created_at": "2016-07-05 09:35:09", "updated_at": "2016-07-05 09:35:09" }, "trim": { "id": 15, "car_model_id": 7, "name": "FR", "created_at": "2016-06-08 10:07:45", "updated_at": "2016-06-08 10:07:45" } } ], "model": { "id": 7, "brand_id": 2, "name": "Ibiza", "created_at": "2016-05-23 12:44:29", "updated_at": "2016-05-23 12:44:29" } }, { "id": 6, "car_brand_id": 2, "car_model_id": 13, "youtube": "", "title": "New Mii range available in Sunderland & Durham - Pulman SEAT ", "description": "Buy a new Mii from Pulman SEAT - Available to test drive in Sunderland & Durham", "slug": "mii", "published": 1, "news": 0, "published_at": "2016-07-05 05:51:57", "created_at": "2016-06-08 10:57:52", "updated_at": "2016-07-05 09:51:57", "offers": [ { "id": 6, "car_page_id": 6, "car_trim_id": 21, "car_type_id": 1, "cap_code_id": null, "car_image_id": 60, "derivative": "3DR 1.0 60PS", "car_position_id": 2, "youtube_code": "", "terms": "At the end of the agreement there are three options: I) retain the vehicle: pay the optional final payment to own the vehicle; ii) return the vehicle; or iii) replace: part exchange the vehicle, subject to status. Available when purchased on Solutions Personal Contract Plan ordered until 30th September 2016. *Payable with first payment. ** Payable with optional final payment. Retail sales only. #4.4p per mile excess mileage charges apply. Further charges may be payable if vehicle is returned. Indemnities may be required. Subject to status. Available to over 18s in the UK only. Offer is subject to vehicle availability and may be varied or withdrawn at any time. † £1,800 deposit contribution available on Mii Design 1.0 3DR when purchased on SEAT Solutions. Finance providers may pay us for introducing you to them. We can introduce you to a limited number of lenders to assist with your purchase, who may pay us for introducing you to them. **Pulman SEAT price match guarantee is available on like for like new SEAT models with identical spec. A genuine quote must be provided within a 15-mile radius. images for illustration purposes only", "status": 1, "created_at": "2016-06-15 08:41:56", "updated_at": "2016-07-04 22:15:25", "image": { "id": 60, "car_image_category_id": 11, "image_name": "Mii-Design", "name": "dbecbdbc29234053e0bf8a09968ad991e7a17492.png", "path": "img/imagedb/dbecbdbc29234053e0bf8a09968ad991e7a17492.png", "thumbnail_path": "img/imagedb/thumbs/tn-dbecbdbc29234053e0bf8a09968ad991e7a17492.png", "created_at": "2016-07-04 12:34:07", "updated_at": "2016-07-04 12:34:07" }, "trim": { "id": 21, "car_model_id": 13, "name": "Design", "created_at": "2016-06-14 09:17:10", "updated_at": "2016-06-14 09:17:10" } } ], "model": { "id": 13, "brand_id": 2, "name": "Mii", "created_at": "2016-06-08 10:54:21", "updated_at": "2016-06-08 10:54:21" } }, { "id": 8, "car_brand_id": 2, "car_model_id": 11, "youtube": "", "title": "New SEAT Leon range available in Sunderland & Durham - Pulman SEAT ", "description": "Buy a new SEAT Leon from Pulman SEAT - Available to test drive in Sunderland & Durham", "slug": "leon", "published": 1, "news": 0, "published_at": "2016-07-05 05:53:33", "created_at": "2016-07-04 08:38:32", "updated_at": "2016-07-05 09:53:33", "offers": [ { "id": 21, "car_page_id": 8, "car_trim_id": 35, "car_type_id": 1, "cap_code_id": null, "car_image_id": 50, "derivative": "5DR 1.2 TSI 110PS", "car_position_id": 19, "youtube_code": "", "terms": "At the end of the agreement there are three options: i) retain the vehicle: pay the optional final payment to own the vehicle; ii) return the vehicle; or iii) replace: part exchange the vehicle, subject to status. Available when purchased on Solutions Personal Contract Plan until 30th September 2016. Retail sales only. *Payable with first payment. ** Payable with optional final payment. #7.2p per mile excess mileage charges apply. Further charges may be payable if vehicle is returned. Indemnities may be required. Subject to status. Available to over 18s in the UK only. Offer is subject to vehicle availability and may be varied or withdrawn at any time. Certain vehicles excluded- ask for full details. † £2,000 deposit contributions available when purchased on SEAT Personal Contract Plan. Retail Sales Only. Finance providers may pay us for introducing you to them. We can introduce you to a limited number of lenders to assist with your purchase, who may pay us for introducing you to them. Images for illustrative purposes only. ", "status": 1, "created_at": "2016-07-05 08:29:28", "updated_at": "2016-07-19 14:03:46", "image": { "id": 50, "car_image_category_id": 12, "image_name": "Leon-SE-5DR", "name": "184484219879badbb5dab51b7421203c2bc16fa0.png", "path": "img/imagedb/184484219879badbb5dab51b7421203c2bc16fa0.png", "thumbnail_path": "img/imagedb/thumbs/tn-184484219879badbb5dab51b7421203c2bc16fa0.png", "created_at": "2016-07-04 12:25:48", "updated_at": "2016-07-04 12:25:48" }, "trim": { "id": 35, "car_model_id": 11, "name": "SE Dynamic", "created_at": "2016-06-14 09:51:20", "updated_at": "2016-06-14 09:51:20" } } ], "model": { "id": 11, "brand_id": 2, "name": "Leon", "created_at": "2016-06-08 10:06:29", "updated_at": "2016-06-08 10:06:29" } }, { "id": 9, "car_brand_id": 2, "car_model_id": 14, "youtube": "", "title": "Lorem", "description": "Lorem", "slug": "ibiza-st", "published": 0, "news": 0, "published_at": "2016-07-04 11:38:48", "created_at": "2016-07-04 13:05:29", "updated_at": "2016-07-04 15:38:48", "offers": [], "model": { "id": 14, "brand_id": 2, "name": "Ibiza ST", "created_at": "2016-06-08 10:54:53", "updated_at": "2016-06-08 10:54:53" } }, { "id": 10, "car_brand_id": 2, "car_model_id": 15, "youtube": "", "title": "New Leon ST range available in Sunderland & Durham - Pulman SEAT ", "description": "Buy a new SEAT Leon ST from Pulman SEAT - Available to test drive in Sunderland & Durham", "slug": "leon-st", "published": 1, "news": 0, "published_at": "2016-07-05 05:54:09", "created_at": "2016-07-04 13:23:23", "updated_at": "2016-07-05 09:54:09", "offers": [ { "id": 22, "car_page_id": 10, "car_trim_id": 48, "car_type_id": 1, "cap_code_id": null, "car_image_id": 53, "derivative": "5DR 1.2 TSI 110PS", "car_position_id": 23, "youtube_code": "", "terms": "At the end of the agreement there are three options: i) retain the vehicle: pay the optional final payment to own the vehicle; ii) return the vehicle; or iii) replace: part exchange the vehicle, subject to status. Available when purchased on Solutions Personal Contract Plan until 30th September 2016. Retail sales only. *Payable with first payment. ** Payable with optional final payment. #7.2p per mile excess mileage charges apply. Further charges may be payable if vehicle is returned. Indemnities may be required. Subject to status. Available to over 18s in the UK only. Offer is subject to vehicle availability and may be varied or withdrawn at any time. Certain vehicles excluded- ask for full details. † £2,000 deposit contributions available when purchased on SEAT Personal Contract Plan. Retail Sales Only. Finance providers may pay us for introducing you to them. We can introduce you to a limited number of lenders to assist with your purchase, who may pay us for introducing you to them. Images for illustrative purposes only.", "status": 1, "created_at": "2016-07-05 08:38:51", "updated_at": "2016-07-19 14:15:41", "image": { "id": 53, "car_image_category_id": 12, "image_name": "Leon-ST-SE", "name": "c743dc09fc1b24c1fac866baf6e3fe3f98f3e6af.png", "path": "img/imagedb/c743dc09fc1b24c1fac866baf6e3fe3f98f3e6af.png", "thumbnail_path": "img/imagedb/thumbs/tn-c743dc09fc1b24c1fac866baf6e3fe3f98f3e6af.png", "created_at": "2016-07-04 12:25:49", "updated_at": "2016-07-04 12:25:49" }, "trim": { "id": 48, "car_model_id": 15, "name": "SE Dynamic", "created_at": "2016-06-14 10:39:16", "updated_at": "2016-06-14 10:39:16" } } ], "model": { "id": 15, "brand_id": 2, "name": "Leon ST", "created_at": "2016-06-08 10:55:21", "updated_at": "2016-06-08 10:55:21" } }, { "id": 11, "car_brand_id": 2, "car_model_id": 16, "youtube": "", "title": " New SEAT Leon Cupra range available in Sunderland - Pulman SEAT ", "description": "Buy a new SEAT Leon Cupra from Pulman SEAT - Available to test drive in Sunderland & Durham", "slug": "leon-cupra", "published": 1, "news": 0, "published_at": "2016-07-05 05:55:06", "created_at": "2016-07-04 13:27:04", "updated_at": "2016-07-05 09:55:06", "offers": [ { "id": 11, "car_page_id": 11, "car_trim_id": 39, "car_type_id": 1, "cap_code_id": null, "car_image_id": 67, "derivative": "SC 2.0 TSI 290PS ", "car_position_id": 11, "youtube_code": "", "terms": "At the end of the agreement there are three options: I) retain the vehicle: pay the optional final payment to own the vehicle; ii) return the vehicle; or iii) replace: part exchange the vehicle, subject to status. Available when purchased on Solutions Personal Contract Plan on vehicles ordered until 30th September 2016. Retail sales only. *Payable with first payment. ** Payable with optional final payment. #7.2p per mile excess mileage charges apply. Further charges may be payable if vehicle is returned. Indemnities may be required. Subject to status. Available to over 18s in the UK only. Offer is subject to vehicle availability and may be varied or withdrawn at any time. Certain vehicles excluded- ask for full details. † £2,500 deposit contribution available when purchased with SEAT finance. * Finance providers may pay us for introducing you to them. We can introduce you to a limited number of lenders to assist with your purchase, who may pay us for introducing you to them. Images for illustrative purposes only. Images for illustration purposes only.", "status": 1, "created_at": "2016-07-04 15:39:03", "updated_at": "2016-07-19 14:03:46", "image": { "id": 67, "car_image_category_id": 16, "image_name": "Leon-Cupra", "name": "860d4b8e32224ccabe5cf4c2b78424b0fccbf0ea.png", "path": "img/imagedb/860d4b8e32224ccabe5cf4c2b78424b0fccbf0ea.png", "thumbnail_path": "img/imagedb/thumbs/tn-860d4b8e32224ccabe5cf4c2b78424b0fccbf0ea.png", "created_at": "2016-07-05 09:22:40", "updated_at": "2016-07-05 09:22:40" }, "trim": { "id": 39, "car_model_id": 16, "name": "290", "created_at": "2016-06-14 10:16:19", "updated_at": "2016-06-14 10:16:19" } } ], "model": { "id": 16, "brand_id": 2, "name": "Leon Cupra", "created_at": "2016-06-08 10:55:28", "updated_at": "2016-06-08 10:55:28" } }, { "id": 12, "car_brand_id": 2, "car_model_id": 17, "youtube": "", "title": " New SEAT Leon X-PERIENCE range available in Sunderland - Pulman SEAT ", "description": "Buy a new SEAT Leon X-PERIENCE from Pulman SEAT - Available to test drive in Sunderland & Durham", "slug": "leon-x-perience", "published": 1, "news": 0, "published_at": "2016-07-05 05:56:46", "created_at": "2016-07-04 13:40:32", "updated_at": "2016-07-05 09:56:46", "offers": [ { "id": 23, "car_page_id": 12, "car_trim_id": 37, "car_type_id": 1, "cap_code_id": 175, "car_image_id": 54, "derivative": "2.0 TDI 150PS", "car_position_id": 24, "youtube_code": "", "terms": "At the end of the agreement there are three options: i) retain the vehicle: pay the optional final payment to own the vehicle; ii) return the vehicle; or iii) replace: part exchange the vehicle, subject to status. Available when purchased on Solutions Personal Contract Plan until 30th September 2016. Retail sales only. *Payable with first payment. ** Payable with optional final payment. #7.2p per mile excess mileage charges apply. Further charges may be payable if vehicle is returned. Indemnities may be required. Subject to status. Available to over 18s in the UK only. Offer is subject to vehicle availability and may be varied or withdrawn at any time. Certain vehicles excluded- ask for full details. † £2,000 deposit contributions available when purchased on SEAT Personal Contract Plan. Retail Sales Only. Finance providers may pay us for introducing you to them. We can introduce you to a limited number of lenders to assist with your purchase, who may pay us for introducing you to them. Images for illustrative purposes only. ^^ This information should be used for illustration purposes only. Standard EU Test figures for comparison purposes, may not reflect real driving results.", "status": 1, "created_at": "2016-07-05 09:43:11", "updated_at": "2016-07-19 14:15:41", "image": { "id": 54, "car_image_category_id": 12, "image_name": "Leon-X-Perience", "name": "e3e791f870ef57ade77d1f04436d423ac9ae5755.png", "path": "img/imagedb/e3e791f870ef57ade77d1f04436d423ac9ae5755.png", "thumbnail_path": "img/imagedb/thumbs/tn-e3e791f870ef57ade77d1f04436d423ac9ae5755.png", "created_at": "2016-07-04 12:25:50", "updated_at": "2016-07-04 12:25:50" }, "trim": { "id": 37, "car_model_id": 17, "name": "SE", "created_at": "2016-06-14 10:11:43", "updated_at": "2016-06-14 10:11:43" } } ], "model": { "id": 17, "brand_id": 2, "name": "Leon X-PERIENCE", "created_at": "2016-06-08 10:55:54", "updated_at": "2016-06-08 10:55:54" } }, { "id": 13, "car_brand_id": 2, "car_model_id": 18, "youtube": "", "title": "New SEAT Toledo range available in Sunderland - Pulman SEAT ", "description": "Buy a new SEAT Toledo from Pulman SEAT - Available to test drive in Sunderland & Durham", "slug": "toledo", "published": 1, "news": 0, "published_at": "2016-07-05 05:56:34", "created_at": "2016-07-04 13:40:48", "updated_at": "2016-07-05 09:56:34", "offers": [ { "id": 19, "car_page_id": 13, "car_trim_id": 50, "car_type_id": 1, "cap_code_id": 197, "car_image_id": 63, "derivative": "1.4 TDI Ecomotive SE", "car_position_id": 18, "youtube_code": "", "terms": "At the end of the agreement there are three options: I) retain the vehicle: pay the optional final payment to own the vehicle; ii) return the vehicle; or iii) replace: part exchange the vehicle, subject to status. Available when purchased on Solutions Personal Contract Plan on vehicles ordered until 30th September 2016. Retail sales only. *Payable with first payment. ** Payable with optional final payment. #7.2p per mile excess mileage charges apply. Further charges may be payable if vehicle is returned. Indemnities may be required. Subject to status. Available to over 18s in the UK only. Offer is subject to vehicle availability and may be varied or withdrawn at any time. Certain vehicles excluded- ask for full details. † £3,250 deposit contribution available on when purchased on SEAT Solutions. Finance providers may pay us for introducing you to them. We can introduce you to a limited number of lenders to assist with your purchase, who may pay us for introducing you to them. Images for illustrative purposes only. ^^ This information should be used for illustration purposes only. Standard EU Test figures for comparison purposes, may not reflect real driving results.", "status": 1, "created_at": "2016-07-05 08:17:55", "updated_at": "2016-07-19 14:03:46", "image": { "id": 63, "car_image_category_id": 14, "image_name": "Toledo-Style-Advanced", "name": "f2ba78e24b7f9286e5c4b37da716e491a99f2d23.png", "path": "img/imagedb/f2ba78e24b7f9286e5c4b37da716e491a99f2d23.png", "thumbnail_path": "img/imagedb/thumbs/tn-f2ba78e24b7f9286e5c4b37da716e491a99f2d23.png", "created_at": "2016-07-04 12:41:54", "updated_at": "2016-07-04 12:41:54" }, "trim": { "id": 50, "car_model_id": 18, "name": "SE", "created_at": "2016-06-14 10:49:09", "updated_at": "2016-06-14 10:49:09" } } ], "model": { "id": 18, "brand_id": 2, "name": "Toledo", "created_at": "2016-06-08 10:56:11", "updated_at": "2016-06-08 10:56:11" } }, { "id": 14, "car_brand_id": 2, "car_model_id": 19, "youtube": "", "title": "New SEAT Alhambra range available in Sunderland - Pulman SEAT ", "description": "Buy a new SEAT Alhambra from Pulman SEAT - Available to test drive in Sunderland & Durham", "slug": "alhambra", "published": 1, "news": 0, "published_at": "2016-07-05 05:57:49", "created_at": "2016-07-04 13:41:03", "updated_at": "2016-07-05 09:57:49", "offers": [ { "id": 15, "car_page_id": 14, "car_trim_id": 54, "car_type_id": 1, "cap_code_id": 3, "car_image_id": 64, "derivative": "2.0 TDI CR 150PS ", "car_position_id": 14, "youtube_code": "", "terms": "At the end of the agreement there are three options: I) retain the vehicle: pay the optional final payment to own the vehicle; ii) return the vehicle; or iii) replace: part exchange the vehicle, subject to status. Available when purchased on Solutions Personal Contract Plan. Retail sales only. Offer available for vehicles ordered before 30th September 2016. *Payable with first payment. ** Payable with optional final payment. #7.2p per mile excess mileage charges apply. Further charges may be payable if vehicle is returned. Indemnities may be required. Subject to status. Available to over 18s in the UK only. Offer is subject to vehicle availability and may be varied or withdrawn at any time. Certain vehicles excluded- ask for full details. † £2,000 deposit contribution available on SEAT Alhambra when purchased on SEAT Solutions. Finance providers may pay us for introducing you to them. We can introduce you to a limited number of lenders to assist with your purchase, who may pay us for introducing you to them. ^^ This information should be used for illustration purposes only. Standard EU Test figures for comparison purposes, may not reflect real driving results. Images for illustrative purposes only.", "status": 1, "created_at": "2016-07-04 15:55:00", "updated_at": "2016-07-19 14:03:46", "image": { "id": 64, "car_image_category_id": 15, "image_name": "Alhambra", "name": "d6a0039805cdb91732992799ef0d52892767a36b.png", "path": "img/imagedb/d6a0039805cdb91732992799ef0d52892767a36b.png", "thumbnail_path": "img/imagedb/thumbs/tn-d6a0039805cdb91732992799ef0d52892767a36b.png", "created_at": "2016-07-04 12:44:19", "updated_at": "2016-07-04 12:44:19" }, "trim": { "id": 54, "car_model_id": 19, "name": "SE", "created_at": "2016-06-14 10:55:55", "updated_at": "2016-06-14 10:55:55" } } ], "model": { "id": 19, "brand_id": 2, "name": "Alhambra", "created_at": "2016-06-08 10:56:23", "updated_at": "2016-06-08 10:56:23" } }, { "id": 15, "car_brand_id": 2, "car_model_id": 20, "youtube": "mJTPmbuxwqQ", "title": "New ATECA range available in Sunderland & Durham - Pulman SEAT ", "description": "Buy a new SEAT ATECA from Pulman SEAT - Available to test drive in Sunderland & Durham", "slug": "ateca", "published": 1, "news": 0, "published_at": "2016-07-07 08:22:04", "created_at": "2016-07-07 09:16:52", "updated_at": "2016-07-07 12:22:04", "offers": [ { "id": 26, "car_page_id": 15, "car_trim_id": 62, "car_type_id": 1, "cap_code_id": null, "car_image_id": 80, "derivative": "1.0 TSI 115PS", "car_position_id": 25, "youtube_code": "", "terms": "At the end of the agreement there are three options: I) retain the vehicle: pay the optional final payment to own the vehicle; ii) return the vehicle; or iii) replace: part exchange the vehicle, subject to status. Available when purchased on Solutions Personal Contract Plan ordered until 30th September 2016. *Payable with first payment. ** Payable with optional final payment. Retail sales only. #4.4p per mile excess mileage charges apply. Further charges may be payable if vehicle is returned. Indemnities may be required. Subject to status. Available to over 18s in the UK only. Offer is subject to vehicle availability and may be varied or withdrawn at any time. Finance providers may pay us for introducing you to them. We can introduce you to a limited number of lenders to assist with your purchase, who may pay us for introducing you to them. ", "status": 1, "created_at": "2016-07-07 12:13:50", "updated_at": "2016-07-19 14:15:41", "image": { "id": 80, "car_image_category_id": 17, "image_name": "Ateca-First", "name": "df14d12b1016b885cf63a47900886322d1c189f9.png", "path": "img/imagedb/df14d12b1016b885cf63a47900886322d1c189f9.png", "thumbnail_path": "img/imagedb/thumbs/tn-df14d12b1016b885cf63a47900886322d1c189f9.png", "created_at": "2016-07-07 09:44:21", "updated_at": "2016-07-07 09:44:21" }, "trim": { "id": 62, "car_model_id": 20, "name": "First Edition", "created_at": "2016-07-07 09:06:31", "updated_at": "2016-07-07 09:06:31" } } ], "model": { "id": 20, "brand_id": 2, "name": "Ateca", "created_at": "2016-07-07 09:04:36", "updated_at": "2016-07-07 09:04:36" } } ] 数组中的对象时,它不会提取任何数据。

目前我可以将数据提取到我的组件中,如下所示:

"offers"

但是如果我尝试从数组中提取数据,那么:

{props.vehicle.model.name}

没有数据被拉到前端,知道如何访问这些数据吗?

谢谢,尼克

1 个答案:

答案 0 :(得分:2)

offersArray的{​​{1}},首先您需要按索引获取Objects元素,然后获取Array属性

Object's

<强>更新

您收到此错误( props.vehicle.offers[0].derivative ),因为您的数据TypeError: Cannot read property 'derivative' of undefined为空offers,例如Array,为空{ {1}}。如果{ id: 9 }为空,则offers offers会返回Array,当您尝试获取属性offers[0]时,它会抛出错误,因为{{1}没有任何属性。你可以添加条件来检查undefined是否包含元素 - Example