简体   繁体   中英

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.

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;

.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. for example ;

<path class="room-bg" />

Note: I'm developing Angular2-Typescript app and I add SVG.js to project as npm package.

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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