简体   繁体   English

如何在具有跨浏览器支持的自定义Dojo构建中包括dojox.gfx.SVG和dojox.gfx.VML?

[英]How to include dojox.gfx.SVG and dojox.gfx.VML in a custom Dojo build with cross-browser support?

I am using dojo.gfx to create vector shapes and text on my website and everything works fine when I am "dojo.require"-ing all dependencies in my Javascript. 我正在使用dojo.gfx在我的网站上创建矢量形状和文本,当我“ dojo.require”-使用Javascript中的所有依赖项时,一切工作正常。 But when I'm building everything I need in a custom build (especially dojox.gfx , dojox.gfx.svg and dojox.gfx.vml ), Dojo's automatic differentiation for SVG-supporting browsers and IEs (VML) seems to be breaking. 但是,当我在自定义版本(尤其是dojox.gfxdojox.gfx.svgdojox.gfx.vml )中构建所需的所有内容时,Dojo对支持SVG的浏览器和IE(VML)的自动区分似乎正在打破。

If I include only dojox.gfx.svg, IE breaks (see below), if I add dojox.gfx.vml, my scripts stop working in Firefox. 如果仅包含dojox.gfx.svg,则IE会中断(请参见下文),如果添加dojox.gfx.vml,则脚本将无法在Firefox中运行。

In IE, the scripts break in the following line of my custom dojo build saying "Object doesn't support property or method": 在IE中,脚本在我的自定义dojo构建的以下行中中断,并显示“对象不支持属性或方法”:

*s.rawNode = _createElementNS(svg.xmlns.svg, "svg");*

with _createElementNS being commented with "Internal helper to deal with creating elements that are namespaced. Mainly to get SVG markup output working on IE.". 带有_createElementNS的注释为“内部助手处理创建命名空间的元素。主要是为了使SVG标记输出可在IE上使用。”。

Right know, I exclude both SVG and VML in my dojo build profile and let dojo xhrGet the rest. 正确的知道,我在我的dojo构建配置文件中同时排除了SVG和VML,而让dojo xhr得到了其余的东西。 This works but requires three more requests (svg.js, shape.js, path.js, although the latter two are included in my build). 这可以工作,但需要三个以上的请求(svg.js,shape.js,path.js,尽管后两个包含在我的构建中)。

What do I need to include in my build to make Vector shapes working in all browsers "out-of-the-box"? 为了使Vector形状在所有浏览器中均可使用,我需要在构建中包括什么?

This is my build profile which works but requires the additional three requests (so neither svg nor vml are included explicitly): 这是我的构建配置文件,可以正常工作,但需要另外三个请求(因此svg和vml均未明确包含):

dependencies ={
layers:  [
    {
    name: "mybuild-dojo.js",
    dependencies: [
     "dojo.fx",
     "dojox.gfx",
     "dojox.gfx.shape",
     "dojox.gfx.path",
     "dojox.gfx.VectorText",
     "dojox.xml.DomParser",
     "dojox.image.Lightbox",
     "dojo.parser"
    ]
    }
],
prefixes: [
    [ "dijit", "../dijit" ],
    [ "dojox", "../dojox" ],
]

}; };

Thank you for your answer. 谢谢您的回答。

Unfortunately the dojox.gfx code is constructed assuming the right renderer (svg or vml) is pulled in at runtime. 不幸的是,dojox.gfx代码是在运行时引入正确的渲染器(svg或vml)的情况下构造的。 So the build you have that just pulls in the top-level dojox.gfx is the way to go. 因此,只需引入顶级dojox.gfx即可构建。

You could probably hack the code to put an if(dojox.gfx.renderer == "svg"){} around the dojox.gfx files for svg. 您可能会修改代码,将if(dojox.gfx.renderer ==“ svg”){}放在svg的dojox.gfx文件周围。 Probably looking at the dojox.gfx source and the dojo.requireIf() calls at the bottom would give an idea on how to wrap each module. 大概看一下dojox.gfx源代码和底部的dojo.requireIf()调用,将为如何包装每个模块提供一个思路。

Have you tried putting: 您是否尝试过:

gfxRenderer:'svg,silverlight,vml'

in your djcongfig settings? 在您的djcongfig设置中?

dojox.gfx article on dojocampus dojocampus上的dojox.gfx文章

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM