0

in vue I have method to read stylesheet files

    let stylesHtml = '';
     for (const node of [...document.querySelectorAll('link[rel="stylesheet"], style')]) {
        stylesHtml += node.outerHTML;
     }

it work in local but fails in productions I need it to print dev content with style

1 Answers1

0

I had a similar issue with something like this , so i always tried to get elements by their classes since i create different various css classes . this also makes me reach any desired element , easily and without any problem . like:

<div class="cssClass" > .... </div>
.
.
elements = document.getElementsByClassName("cssClass");

This can make your code to also look cleaner and easier to read .

Jacobify
  • 15
  • 9
  • 1
    but I wont to get style links ( css files ) to add it to print page – Tasneem HamedAlneel Aug 09 '21 at 06:04
  • Okay so i can refer you to these . I think you can find your solution there. https://stackoverflow.com/questions/6209161/extract-the-current-dom-and-print-it-as-a-string-with-styles-intact https://stackoverflow.com/questions/4867005/extracting-only-the-css-used-in-a-specific-page – Jacobify Aug 09 '21 at 06:29