<el-dialog title="打印" :visible="dialogJISVisible_hot" :close-on-click-modal = "false">
<div id="rmz_PrintID" v-for="(dialogData,index) in dialogDataList" :key="index" >
<div>
<table>
<tr>
<td>{{dialogData.col1}}</td>
<td>{{dialogData.col2}}</td>
</tr>
<tr>
<td>11</td>
<td>22</td>
</tr>
</table>
</div>
</div>
<div slot="footer" class="dialog-footer">
<div class="footerbutton">
<el-button type="primary" @click="surePrint_hot">确定打印</el-button>
<el-button type="primary" v-print="printObj_hot" name="print" class="print" ref="print"></el-button>
<el-button @click="closedialog">关闭</el-button>
</div>
</div>
</el-dialog>
data变量 v-print 里的ID对应DIV的ID
printObj_hot: {
id: 'rmz_PrintID',
popTitle: '打印',
},
解决方案:
查文档发现v-print取值方式是取得 ID为rmz_PrintID的所有内容
将循环放在rmz_PrintID里面就OK了
<el-dialog title="打印" :visible="dialogJISVisible_hot" :close-on-click-modal = "false">
<div id="rmz_PrintID" >
<div v-for="(dialogData,index) in dialogDataList" :key="index" >
<table>
<tr>
<td>{{dialogData.col1}}</td>
<td>{{dialogData.col2}}</td>
</tr>
<tr>
<td>11</td>
<td>22</td>
</tr>
</table>
</div>
</div>
<div slot="footer" class="dialog-footer">
<div class="footerbutton">
<el-button type="primary" @click="surePrint_hot">确定打印</el-button>
<el-button type="primary" v-print="printObj_hot" name="print" class="print" ref="print"></el-button>
<el-button @click="closedialog">关闭</el-button>
</div>
</div>
</el-dialog>