更正前端内容
This commit is contained in:
@@ -131,17 +131,16 @@ export default {
|
|||||||
const finalCanvasHeight = containerHeight * printScale;
|
const finalCanvasHeight = containerHeight * printScale;
|
||||||
|
|
||||||
// 使用合适的scale值生成高清Canvas(但不超过纸张尺寸)
|
// 使用合适的scale值生成高清Canvas(但不超过纸张尺寸)
|
||||||
const canvasScale = Math.min(1.5, printScale * 1.5); // 确保不超过纸张
|
const canvasScale = Math.min(2, printScale * 2); // 适当提高清晰度
|
||||||
|
|
||||||
// 4. 用html2canvas生成高清Canvas(解决文字模糊+二维码丢失)
|
// 4. 用html2canvas生成高清Canvas(解决文字模糊+二维码丢失)
|
||||||
|
// 注意:不再强制指定 width/height,避免裁掉最右/最下边框
|
||||||
const canvas = await html2canvas(labelContainer, {
|
const canvas = await html2canvas(labelContainer, {
|
||||||
scale: canvasScale,
|
scale: canvasScale,
|
||||||
backgroundColor: '#ffffff', // 强制白色背景,避免打印时背景透明
|
backgroundColor: '#ffffff', // 强制白色背景,避免打印时背景透明
|
||||||
useCORS: true, // 支持跨域图片
|
useCORS: true, // 支持跨域图片
|
||||||
allowTaint: true, // 允许渲染canvas(二维码)
|
allowTaint: true, // 允许渲染canvas(二维码)
|
||||||
taintTest: false, // 关闭canvas污染检测
|
taintTest: false, // 关闭canvas污染检测
|
||||||
width: containerWidth,
|
|
||||||
height: containerHeight,
|
|
||||||
logging: false,
|
logging: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user