我正在返回一个对象,我希望它能够循环并通过类或 ID 将其内容绑定到 DOM 对象。
有没有推荐的方法来做到这一点而不必手动分配每个元素?
最佳案例场景是一个函数,它实际上将创建一个包含数据的元素。
...否则我会手动创建和分配所有数据,而且还有很多。
{
"user_profile": {
"user_meta_first_name": "asdasd",
"user_meta_last_name": "asdasd",
"user_meta_billing_first_name": "asdasd",
"user_meta_billing_last_name": "asdasd",
"user_meta_billing_address_1": "2589 asdasd Rd.",
"user_meta_billing_address_2": "",
"user_meta_billing_city": "asdsdasd",
"user_meta_billing_postcode": "VVV 344",
"user_meta_billing_country": "CA",
"user_meta_billing_state": "AB",
"user_meta_billing_email": "admin@thebandagency.ca",
"user_meta_billing_phone": "2343423434",
"user_meta_shipping_first_name": "asdasd",
"user_meta_shipping_last_name": "asdasd",
"user_meta_shipping_address_1": "2589 asdasd Rd.",
"user_meta_shipping_address_2": "",
"user_meta_shipping_city": "asdasd",
"user_meta_shipping_postcode": "VVV 344",
"user_meta_shipping_country": "CA",
"user_meta_shipping_state": "AB",
"user_meta_shipping_email": "",
"user_meta_shipping_phone": "",
"user_meta_paying_customer": "1"
},
"pet_profiles": {
"2000": {
"pet_name": "Wally the Wonder Pup",
"pet_tag_serial": "V140000",
"pet_tag_pin": "XGZSVEMZ",
"pet_tag_expiry": "December 8, 2013",
"pet_tag_active": "1",
"pet_tag_size": "1",
"pet_tag_design": "Basket Case"
}
}
}