Cocoonjs 无法渲染父容器(它是一个 div)。您需要覆盖 Kinetic 的原型。
Kinetic.Stage.prototype._buildDOM = function() {
this.content = this.attrs.container;
this.hitCanvas = new Kinetic.Canvas(0, 0, true);
this.bufferCanvas = new Kinetic.SceneCanvas({
pixelRatio: 1
});
this.bufferHitCanvas = new Kinetic.HitCanvas();
this._resizeDOM();
};
Kinetic.Stage.prototype._getContentPosition = function() { var rect = this.content.getBoundingClientRect ?this.content.getBoundingClientRect() : { top : 0, left : 0 }; 返回{顶部:rect.top,左侧:rect.left};};
然后像这样构建你的主要阶段。
this.stage = new Kinetic.Stage({width: 960, height: 500, container: document.body});