Home >Web Front-end >JS Tutorial >vue.js implements printer connection

vue.js implements printer connection

零到壹度
零到壹度Original
2018-03-26 10:16:075367browse

This article mainly introduces how to connect the printer with vue.js. The article introduces it in detail through the sample code, which has certain reference and learning value. I hope it can help everyone.

<p class="dialogCare">
        <span>hello word!</span>   //要打印的内容</p>
<button  @click="printBtn()">打 印</button>
 printBtn(){      let newstr = document.getElementsByClassName(&#39;dialogCare&#39;)[0].innerHTML;
      console.log(newstr)
      window.document.body.innerHTML = newstr;      let oldstr = window.document.body.innerHTML;
      window.print();
      window.location.reload();   //解决打印之后按钮失效的问题
      window.document.body.innerHTML = oldstr;      return false;
    },

Related recommendations:

jquery connects to the printer

API connects to the printer

JAVA connects to printer to print receipt

The above is the detailed content of vue.js implements printer connection. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn