每次单击矩形时,我都会尝试增加文本值。我究竟做错了什么 ?我不明白,因为对我的 var 的调用在 drawText 中有效,但在 setLayer 中无效。我查看了使用“+=”语法的“setLayer”源代码,但文本是一个字符串变量,我不想进行字符串连接。
value=1
$('canvas').drawText({
name: 'count',
fillStyle: '#0f0',
x: 20, y: 20,
fontSize: 22,
fontFamily: 'Verdana, sans-serif',
text: value
})
.drawRect({
strokeStyle: '#000',
fillStyle: '#ccc',
x: 20, y: 50,
width: 20,
height: 20,
layer: true,
click: function(layer) {
// Spin
$(this).animateLayer(layer, {
rotate: '+=180'
});
v=parseInt(value);
$(this).setLayer('count',{
text: value+1 // TRYING to increment over here
});
}})