一般情况下,v-print打印是点击标签马上就调用的, 像这种
<el-button @click="srueClick" type="primary" >确 定</el-button>
但是现在需求是要先弹出对话框,让用户选择是否打印
上代码
<el-button @click="srueClick" type="primary" >确 定</el-button>
<div v-show="false" v-print="'#printContent'" ref="replaceCancel"></div>
srueClick(){
this.$message('是否打印小票?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
closeOnClickModal: false
}).then(() => {
this.$refs.replaceCancel.click()
})
}
如果实在普通方法里调用,那直接this.$refs.replaceCancel.click()就行了。
<el-button @click="srueClick" type="primary" >确 定</el-button>
<div v-show="false" v-print="'#printContent'" ref="replaceCancel"></div>
srueClick(){ this.$refs.replaceCancel.click()}