1、遍歷
var json={ "name":"喬峰", "age":"10", "sex":"男" }; for(var key in json){ console.log(key+":"+json[key]); }
2、通過下表獲取
var ViewType = { a: "a", b: "b", c: "c" }; var keys = Object.keys(ViewType) var values = Object.values(ViewType) console.log(keys[1] + ':' + values[1])
此字典無法在QML中聲明,不然會報錯: javascript declaration outside script element