为什么我按照文档来添加事件会没有响应?
<!DOCTYPE html>
Title
<script type="text/javascript">
window.onload = function () {
var stage = new Kinetic.Stage({
container: "container",
width: 600,
height: 400
});
var layer = new Kinetic.Layer();
var config = {
x: 0,
y: 0,
fill: 'green',
drawFunc: function () {
var ctx = this.getContext();
ctx.beginPath();
ctx.rect(5, 5, 100, 115);
ctx.fill();
// ctx.moveTo(0, 200);
// ctx.lineTo(0, 200);
// ctx.lineTo(40, 120);
// ctx.lineTo(80, 230);
// ctx.lineTo(120, 250);
// ctx.lineTo(160, 190);
// ctx.lineTo(250, 110);
// ctx.strokeShape(this);
},
stroke: 'red',
lineJoin: 'round',
//detectionType: 'pixel',
strokeWidth: 2,
listening: true
};
var shape = new Kinetic.Shape(config);
shape.on("click", function () {
console.log("你点击了该矩形");
});
layer.add(shape);
stage.add(layer);
// stage.draw();
};