Javascript 用`setAttribute'设置Raphael中的双边框`

Javascript 用`setAttribute'设置Raphael中的双边框`,javascript,svg,raphael,Javascript,Svg,Raphael,在本文中,我有两个SVG矩形。第一个在SVG标记中,第二个用Raphael JS呈现。两个矩形都应该与双边框相同,但它们不是。在Raphael JS中使用node.setAttribute应该设置低级SVG属性,因此这应该可以工作。这里少了什么 <svg height="100" width="100"> <rect class="rect2" height="50" width="50" x='25' y='25' /> </svg> <div

在本文中,我有两个SVG矩形。第一个在SVG标记中,第二个用Raphael JS呈现。两个矩形都应该与双边框相同,但它们不是。在Raphael JS中使用
node.setAttribute
应该设置低级SVG属性,因此这应该可以工作。这里少了什么

<svg height="100" width="100">
  <rect class="rect2" height="50" width="50" x='25' y='25' />
</svg>

<div id="the_canvas"></div>


.rect2 {
  fill: none;
  outline: 2px double black;
  outline-offset: 0;
}


var w = 100, h = 100;
var paper = Raphael("the_canvas", w, h); 

var rect = paper.rect(25,25,50,50);
rect.node.setAttribute('fill', 'none');
rect.node.setAttribute('outline','2px double black');
rect.node.setAttribute('outline-offset', 0);

.2{
填充:无;
外形:2倍双黑;
轮廓偏移:0;
}
var w=100,h=100;
var paper=拉斐尔(“画布”,w,h);
var rect=paper.rect(25,25,50,50);
rect.node.setAttribute('fill','none');
setAttribute('outline','2px双黑');
rect.node.setAttribute('outline-offset',0);

这不是拉斐尔的问题,而是SVG的工作方式

outline和outline offset不是映射的SVG属性。也就是说,它们不映射到CSS属性。事实上,这两个CSS属性都不应该在SVG中真正起作用(SVG规范中没有提到它们)


浏览器的存在主要是为了呈现HTML,有时只有在HTML中才能工作的东西会在SVG中出现,而它们在SVG中应该没有效果。

谢谢。你对拉斐尔的双线边框有什么建议?只需创建一个额外的矩形?绘制两个大小稍有不同的矩形元素,每个元素有一个笔划。