简体   繁体   English

将样式从外部 scss 文件添加到 SVG.js 元素

[英]Add style from external scss file to SVG.js element

I create a svg and add a path to it with SVG.js as follow.我创建了一个 svg 并使用 SVG.js 添加了一个路径,如下所示。

this.roomPlan = SVG('roomPlan').attr('id','roomPlanSvg').size(1024, 
768);
this.roomPlan.path(room.area.d);

I have a external .scss file and I have some style as follow;我有一个外部.scss文件,我有一些样式如下;

.room-bg {
  fill: nb-theme(card-bg);
  stroke: transparent;
  cursor: pointer;
  stroke-width: 4px;
}

I want to add .room-bg selector to my path element as class like other html.我想像其他 html 一样将.room-bg选择器作为类添加到我的路径元素中。 for example ;例如 ;

<path class="room-bg" />

Note: I'm developing Angular2-Typescript app and I add SVG.js to project as npm package.注意:我正在开发Angular2-Typescript应用程序,并将SVG.js添加到项目中作为 npm 包。

Thanks for helps.感谢您的帮助。

You should just be able to do:你应该能够做到:

this.roomPlan.path(room.area.d).addClass("room-bg");

See: [http://svgjs.dev/manipulating/#addclass]见:[http://svgjs.dev/manipulating/#addclass]

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

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