按结果迭代

时间:2019-04-23 12:54:04

标签: vue.js

我必须遍历组和组内部,我需要针对每个组进行遍历。

这是我得到的答复:

{
    "message": "",
    "status": "success",
    "response": {
        "Te dhenat e Klientit": [
            {
                "id": 1,
                "specification": "Personal Accidents",
                "header": "Te dhenat e Klientit",
                "item": "Veprimtaria",
                "type": "text"
            },
            {
                "id": 2,
                "specification": "Personal Accidents",
                "header": "Te dhenat e Klientit",
                "item": "Numri i Siguruarve",
                "type": "text"
            },
            {
                "id": 3,
                "specification": "Personal Accidents",
                "header": "Te dhenat e Klientit",
                "item": "Mosha Mesatare",
                "type": "text"
            },
            {
                "id": 4,
                "specification": "Personal Accidents",
                "header": "Te dhenat e Klientit",
                "item": "Tjere",
                "type": "text"
            }
        ],
        "Shuma e Sigurimit": [
            {
                "id": 5,
                "specification": "Personal Accidents",
                "header": "Shuma e Sigurimit",
                "item": "Objekti i Sigurimit",
                "type": "list"
            }
        ],
        "Mbulimet e Kerkuara": [
            {
                "id": 6,
                "specification": "Personal Accidents",
                "header": "Mbulimet e Kerkuara",
                "item": "Mbulimi",
                "type": "list"
            }
        ],
        "Shenime": [
            {
                "id": 7,
                "specification": "Personal Accidents",
                "header": "Shenime",
                "item": "Shenime",
                "type": "text"
            }
        ],
        "Primi total per Person": [
            {
                "id": 8,
                "specification": "Personal Accidents",
                "header": "Primi total per Person",
                "item": "Primi Neto",
                "type": "text"
            },
            {
                "id": 9,
                "specification": "Personal Accidents",
                "header": "Primi total per Person",
                "item": "TVSH(18%)",
                "type": "text"
            },
            {
                "id": 10,
                "specification": "Personal Accidents",
                "header": "Primi total per Person",
                "item": "Primi Total",
                "type": "text"
            }
        ]
    }
}

因此您可以看到有几个组,每个组中都有项目,我需要获取组名称并显示它,然后迭代每个组中的项目以使用该数据。

1 个答案:

答案 0 :(得分:1)

const inputText = await page.evaluate(() => { 
    return new Promise((resolve, reject) => { 
        let sendButton = document.querySelector(".button"); 
        sendButton.addEventListener("click", () => { 
            let text = document.querySelector(".input").value; 
            resolve(text); 
        }, false); 
    }); 
});
data() {
    return {
        response: {},
    }
},
methods: {
    fetch() {
        axios.get('DATA_URL').then(({response}) => {
            // here is json response of GET request. Assign it to this.response
            this.response = response.data
        })
    }
}

相关问题