我认为您应该在声明弹出对象后初始化 itemlist 变量。
Kinetic 似乎在其构造方法中不接受用户变量。
<!DOCTYPE HTML>
<html>
<head>
<style>
body {
margin: 0px;
padding: 0px;
}
</style>
<script src="http://www.html5canvastutorials.com/libraries/kinetic-v3.10.5.js"></script>
<script>
function draw() {
var stage = new Kinetic.Stage({
container : "container",
width : 800,
height : 600
});
var layer = new Kinetic.Layer();
var popup = new Kinetic.Shape({
drawFunc: function(context) {
context.fillText(this.itemlist[0], 10,10);
context.fillText(this.itemlist[1], 10,50);
context.fillText(this.itemlist[2], 10,90);
this.fill(context);
this.stroke(context);
},
fill: "red",
stroke: "green", strokeWidth:1
});
popup.itemlist = ["one", "two", "three"];
layer.add(popup);
// Add the layer to the stage
stage.add(layer);
};
window.onload = draw;
</script>
</head>
<body>
<div id="container"></div>
</body>
</html>