[英]Uncaught TypeError: Illegal constructor – Using Bonsai.JS in Backbone.JS
I'm still new to js and I'm trying to fit bonsai.js into a backbone app. 我对JS还是陌生的,我正在尝试将bonsai.js集成到主干应用程序中。
I'm following this guide here: https://github.com/iamdustan/bonsai-demos , and trying to 'Separate Things Out' by putting the animation into a separate file titled hero-animation.js
, but I get an Uncaught TypeError: Illegal constructor
on the first line of hero-animation.js
我在这里遵循此指南: https : //github.com/iamdustan/bonsai-demos ,并尝试通过将动画放入名为
hero-animation.js
的单独文件中来尝试“分离事物”,但是我被Uncaught TypeError: Illegal constructor
hero-animation.js
第一行中的Uncaught TypeError: Illegal constructor
This is called in my Backbone router, and is working fine... 这在我的Backbone路由器中称为,并且工作正常...
homeAnimation: function() {
bonsai.run(document.getElementById('heroContent'), {
url: 'hero-animation.js',
width: 500,
height: 400
});
}
Here is what I have in hero-animation.js which is resulting in an error on line 1: 这是hero-animation.js中的内容,这导致第1行出现错误:
var rect = new Rect(0, 0, 200, 200);
rect
.fill('random')
.addTo(stage)
.attr({
x: stage.width - rect.attr('width'),
y: stage.width - rect.attr('height')
})
.animate('0.5s', {
x: 0,
y: 0
});
Seems like you forgot to include bonsai.js
. 好像您忘了包含
bonsai.js
。
Initially, Rect
is an "interface" , which means it can't be used as a constructor, and Bonsai overrides it for its own purposes. 最初,
Rect
是一个“接口” ,这意味着它不能用作构造函数,而Bonsai出于其自身目的重写了它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.