search

Home  >  Q&A  >  body text

javascript - How to print the content of a specified area on a webpage written in Vue? ?

The webpage written by vue needs to print the content of the specified area, retain the original webpage style, and the original webpage content cannot be changed after printing, and jqprint cannot be used. How can this be achieved?

仅有的幸福仅有的幸福2793 days ago901

reply all(4)I'll reply

  • 習慣沉默

    習慣沉默2017-05-19 10:45:23

    @media print {
        .not-print {
            opacity: 0
        }
    }

    In the area you don’t want to print, add the .not-print class~
    A rough way. . .

    reply
    0
  • 怪我咯

    怪我咯2017-05-19 10:45:23

    Basically the idea on the first floor, media queries are hidden in blocks that do not need to be printed when printing.
    You can use opacity or visibility to hide.

    reply
    0
  • 天蓬老师

    天蓬老师2017-05-19 10:45:23

    http://stackoverflow.com/ques...

    mywindow.document.write(this.$el.innerHTML);

    reply
    0
  • PHP中文网

    PHP中文网2017-05-19 10:45:23

    Print part of the web page

    var createPdf = () => {
        let newWindow = window.open("_blank");   //打开新窗口
        let codestr = document.getElementById("pdf-wrap").innerHTML;   //获取需要生成pdf页面的p代码
        newWindow.document.write(codestr);   //向文档写入HTML表达式或者JavaScript代码
        newWindow.document.close();     //关闭document的输出流, 显示选定的数据
        newWindow.print();   //打印当前窗口
        return true;
    }

    reply
    0
  • Cancelreply