簡體   English   中英

根據mootools中數組的值遍歷json對象

[英]Iterate through a json object based on the value of an array in mootools

我有這段代碼:

['design','finish','grills'].each(function(type) {

    this.json.type.each(function(obj, index) {
        console.log(obj);
    });

}.bind(this));

並得到這個錯誤:

this.json.type is undefined

我如何去制作type一個有效的事情的each上? 我不確定正確的術語,因此對此的任何幫助也將是一個加成:)

我想到了:

['design','finish','grills'].each(function(type) {

    this.json[type].each(function(obj, index) {
        console.log(obj);
    });

}.bind(this));

怎么樣:

['design','finish','grills'].each(function(type) {

    this.json[type].each(function(obj, index) {
        console.log(obj);
    });

}.bind(this));

當前,您的代碼正在嘗試查找一個名為type的屬性,而不是該變量包含的鍵。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM