Javascript &引用;jcanvas“;我能';“得不到”;“数据属性”;在层本身内

Javascript &引用;jcanvas“;我能';“得不到”;“数据属性”;在层本身内,javascript,object,layer,jcanvas,Javascript,Object,Layer,Jcanvas,我可以从图层中获取数据 我无法在层本身中获取数据。一个简单实用的解决方案是事先指定数据对象,以便在drawRect()调用的范围内访问它: // second case $('canvas').drawRect({ layer: true, data: { w: 300 }, fillStyle: '#585', x: 100, y: 100, width: $('canvas').getLayer(0).data.w, height: 50 }); 您以前

我可以从图层中获取数据



我无法在层本身中获取数据。

一个简单实用的解决方案是事先指定数据对象,以便在
drawRect()调用的范围内访问它:

// second case

$('canvas').drawRect({

  layer: true,

  data: { w: 300 },

  fillStyle: '#585',

  x: 100, y: 100,

  width: $('canvas').getLayer(0).data.w, height: 50

});
您以前可以使用GetLayer()吗?把它赋给一个变量,然后把它放回去

但是如果您从jCanvas外部跟踪它,正如我理解的jCanvas的目的一样,您不应该担心jCanvas的外部数据。。而是动态地抓取图层属性并进行调整

我的项目也有同样的问题

// second case

$('canvas').drawRect({

  layer: true,

  data: { w: 300 },

  fillStyle: '#585',

  x: 100, y: 100,

  width: $('canvas').getLayer(0).data.w, height: 50

});
var rectData = { w: 300 };

$('canvas').drawRect({

  layer: true,

  data: rectData,

  fillStyle: '#585',

  x: 100, y: 100,

  width: rectData.w, height: 50

});