handlePrint () {
let userAgent = navigator.userAgent;
//判断是否Firefox浏览器
if
(userAgent.indexOf(
"Firefox"
) > -1) {
console.log(
'Firefox'
)
printJS({
printable:
'mytable1'
,
// 标签元素id
type:
'html'
,
header:
''
,
style: `@page {size:auto;margin-top:100px; margin-left:15px; margin-right: 15px;}
thead th {
border-top: 1px solid
#000;
border-right: 1px solid
#000;
border-left: 1px solid
#000;
}
tbody td {
border: 1px solid
#000;
}
tbody {
text-align: center;
}
table {
border-collapse: collapse;
}`,
});
}
//判断是否chorme浏览器
if
(userAgent.indexOf(
"Chrome"
) > -1){
console.log(
'Chrome'
)
printJS({
printable:
'mytable1'
,
// 标签元素id
type:
'html'
,
header:
''
,
documentTitle:
''
,
style: `@page {size:auto;margin-top:100px; margin-left:5px; margin-right: 15px;}
thead th {
border-top: 1px solid
#000;
border-right: 1px solid
#000;
border-left: 1px solid
#000;
}
tbody td {
border: 1px solid
#000;
}
tbody {
text-align: center;
}
table {
border-collapse: collapse;
}`,
});
}
//判断是否IE浏览器
if
(!!window.ActiveXObject ||
"ActiveXObject"
in
window) {
console.log(
'IE'
)
printJS({
printable:
'mytable1'
,
// 标签元素id
type:
'html'
,
header:
''
,
style: `@page {size:auto;margin-top:100px; margin-left:15px; margin-right: 15px;}
thead th {
border-top: 1px solid
#000;
border-right: 1px solid
#000;
border-left: 1px solid
#000;
}
tbody td {
border: 1px solid
#000;
}
tbody {
text-align: center;
}
table {
border-collapse: collapse;
}`,
});
}
},