vue---iframeの印刷コンポーネント
790 ワード
//
//
this.printHtml = document.getElementById("").innerHTML
this.printIframeshow = false
export default {
name:"print",
props:{
html:{
type:String,
default:""
}
},
mounted(){
this.setBodyHtml(this.html)
},
methods:{
setBodyHtml(html){
const document = window.document
const iframe = window.frames[0]
iframe.document.head.innerHTML = document.head.innerHTML
iframe.document.body.innerHTML = html
iframe.window.print()
}
}
}