前端vue打印功能实现

 

methods:{

方法

print(obj){

    var newWindow = window.open("打印窗口","_blank");

    var docStr = obj.innerHTML;

 

    newWindow.document.write('');

    newWindow.document.write('');


 

    newWindow.document.write(docStr);

    newWindow.document.close();

    newWindow.print();

    newWindow.close();

}

点击事件

printCheckoutDetail: function(){

                var _this = this

                var obj = _this.$refs.checkout;

                this.print(obj);

            },

}

html部分

      

          { {bill.billTitle}} { {bill.orderDesc}}

          

               

          

      

      打印

你可能感兴趣的:(javascript,vue.js)