0
[Object, Object, Object]
每个对象的列表中有
Object {x: 1, y: 0, width: 4, height: 5, max_width: undefined…}
和其他一些参数。每个对象是具有数据属性<div id="panel" data-panel-id="2">
的<div>
元素。我怎样才能得到data-panel-id
的价值?
我已经试过
items.forEach(function (item) {
console.log(item);
console.log(item.el);
console.log(item.el.firstNode);
console.log(item.el.firstNode.dataset);
等
我想,如果我用document.getElementById("panel").dataset.panelId
但我的列表中包含的对象,而不是HTML元素,所以我不知道怎么做了它的工作。
我的对象列表是通过onChange侦听器中的gridstack.js库(https://github.com/troolee/gridstack.js)创建的。