我想以编程方式在画布上选择一个对象。该对象具有自定义属性:“id”。如何遍历传递id(Kenteken)的对象并选择id匹配的对象?错误:“0x800a138f - JavaScript运行时错误:无法获取未定义的属性'id'或null”
function selecteerObject() {
var canvobjects = canvas.getObjects();
for (var i = 0; i <= canvobjects.length; i++) {
var idi = canvobjects[i].id;
if (idi = '<%= Request.QueryString("Kenteken")%>')
canvas.setActiveObject(canvas.item[i]);
}
}
}
答案 0 :(得分:0)
你过度循环了一次。将for (var i = 0; i <= canvobjects.length; i++) {
更改为
for (var i = 0; i < canvobjects.length; i++) {
// ^