首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >enyo框架集成了哪个raphael

enyo框架集成了哪个raphael
EN

Stack Overflow用户
提问于 2015-06-11 18:54:09
回答 1查看 82关注 0票数 0

我试图将Raphael与enyo.js集成起来,使用Raphael而不是enyo创建SVG组件,这样我就可以使用Raphael的一些功能。我想将默认呈现的div替换为子组件svg,我已经在jsfiddle下面创建了它。有人能帮我修好吗?

http://jsfiddle.net/stackit/uzjafamo/8/

代码

代码语言:javascript
运行
复制
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"));
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-06-14 16:21:49

我看着你的小提琴,看到了一点可以改进的地方。最初,jsFiddle容器给我带来了一些麻烦,直到我出于某种原因才把它分叉。

以下是我想出的:http://jsfiddle.net/Djspaceg/5qyLej05/4/

代码语言:javascript
运行
复制
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"));

它只会产生一个空的拉斐尔画布。

干杯!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30789133

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档