I'm getting several SVG's that are all structured like this:
<?xml version="1.0" encoding="utf-8"?>
<svg>
...
<g id="cabin">
<g id="1">
<g id="a">
<rect />
<path />
</g>
<g id="b">
<rect />
<path />
</g>
</g>
<g id="2">
<g id="a">
<rect />
<path />
</g>
<g id="b">
<rect />
<path />
</g>
</g>
...
</g>
</svg>
I'm loading the SVG via the html-loader
<div ref="plan" v-html="require('!html-loader!../assets/plaene/plan_1.svg')"></div>
I'm trying to access all child notes of cabin
to change the style
of the rect
items. How should I do this? I tried this before in a single html
-file with plain javascript
var plan = document.getElementById("plan");
plan.addEventListener("load",function() {
dom = plan.contentDocument;
let cabins = dom.getElementById('cabin');
...
and so on
but I don't know how to do this in vue
. I have read some articles (e.g. VueJS — Tips & Best Practices) which say that you shold avoid manipulating the DOM directly, so I guess there must be something else.
Has somebody a solution for this? Thank you in advance!