A
A
asferot2019-01-22 15:06:53
Vue.js
asferot, 2019-01-22 15:06:53

Page template?

How can I print a specific area of ​​a page in vue?
I did it like this, but print goes without css, just bare html. How can this be fixed?
<div id="printableArea"> текст </div>

<a @click="printPageArea('printableArea')">Print</a>

methods: {
        printPageArea(areaID){
            var printContent = document.getElementById(areaID);
            var WinPrint = window.open('', '', 'width=900,height=650');
            WinPrint.document.write(printContent.innerHTML);
            WinPrint.document.close();
            WinPrint.focus();
            WinPrint.print();
            WinPrint.close();
        }
     },

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
coderisimo, 2019-01-22
@asferot

The media rule allows you to specify the type of media for which the specified style will be applied.

Just write the desired style for printing
https://habr.com/en/post/160997/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question