我试图将Raphael与enyo.js集成起来,使用Raphael而不是enyo创建SVG组件,这样我就可以使用Raphael的一些功能。我想将默认呈现的div替换为子组件svg,我已经在jsfiddle下面创建了它。有人能帮我修好吗?
http://jsfiddle.net/stackit/uzjafamo/8/
代码
enyo.kind({
name: "Board",
kind: "enyo.Control",
paper: null,
create: function(){
this.inherited(arguments);
},
rendered: function(){
this.inherited(arguments);
if(this.hasNode()){
paper = Raphael(this.hasNode().id, 100, 100);
}
}
})
enyo.kind({
name: "pages",
kind: "enyo.Control",
create: function(){
this.inherited(arguments);
this.loadView();
},
loadView: function(){
if(!this.$.board){
var com = this.createComponent({
name: "board",
kind: "Board",
},{
owner: this
});
com.render();
}
}
});
new pages().renderInto(document.getElementById("cans"));发布于 2015-06-14 16:21:49
我看着你的小提琴,看到了一点可以改进的地方。最初,jsFiddle容器给我带来了一些麻烦,直到我出于某种原因才把它分叉。
以下是我想出的:http://jsfiddle.net/Djspaceg/5qyLej05/4/
enyo.kind({
name: "Board",
kind: "enyo.Control",
paper: null,
create: function () {
this.inherited(arguments);
},
rendered: function () {
this.inherited(arguments);
if (this.hasNode() && !this.paper) {
this.generateRaphael();
}
},
generateRaphael: function () {
this.paper = Raphael(this.hasNode().id, 100, 100);
}
});
enyo.kind({
name: "pages",
kind: "enyo.Control",
create: function () {
this.inherited(arguments);
this.loadView();
},
loadView: function () {
if (!this.$.board) {
var com = this.createComponent({
name: "board",
kind: "Board",
});
com.render();
}
}
});
new pages().renderInto(document.getElementById("cans"));它只会产生一个空的拉斐尔画布。
干杯!
https://stackoverflow.com/questions/30789133
复制相似问题