Clé*_*yer 4 javascript foreach jquery mashup qliksense
我目前正在 Qlik Sense 中使用 JavaScript 和 jQuery 构建混搭。我做了一些数据选择,并将它们放入变量对象中:
var CurrentSelec = app1.selectionState().selections;
console.log(CurrentSelec);`
console.log(typeof CurrentSelec);
Run Code Online (Sandbox Code Playgroud)
这是我在浏览器控制台上得到的结果:
我试图在 Foreach 中显示 qSelected 值:
我尝试过使用Javascript:
for(var index in CurrentSelec) {
console.log(index.qSelected);
}
Run Code Online (Sandbox Code Playgroud)
我尝试过使用 jQuery:
$.each(CurrentSelec, function(i, index) {
console.log(index.qSelected)
});
Run Code Online (Sandbox Code Playgroud)
但我的浏览器控制台不显示我的foreach日志。
您知道如何正确创建对象的foreach并在浏览器控制台上显示其内容吗?
问候。
小智 9
您可以使用 Object.keys() 方法,该方法返回对象中的键数组。然后我们通过 Array.forEach() 方法运行它。例如
Object.keys(lunch).forEach(function (item) {
console.log(item); // key
console.log(lunch[item]); // value
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15665 次 |
| 最近记录: |