闫增涛
2024-11-06 56cdf07f8496685ba906ea75e7eb2faebb35371b
src/components/paint/index.vue
@@ -1,6 +1,6 @@
<template>
  <div class="paint">
    <canvas id="canvas" width="400" :height="canvasHeight"></canvas>
    <canvas id="canvas" :width="canvasWidth" :height="canvasHeight"></canvas>
    <!-- 操作按钮 -->
    <ul class="paint-btn">
      <li class="paint-btn-box">
@@ -55,6 +55,7 @@
export default {
  data() {
    return {
      canvasWidth:400,
      backgroundImgUrl: "", // 背景
      isDraw: true, // 绘画、框选模式
      brush: "Pencil", // 画笔类型
@@ -126,9 +127,15 @@
    },
  },
  mounted() {
    this.handleCanvasWidth()
    this.init();
  },
  methods: {
    handleCanvasWidth() {
      if(window.innerWidth < 450) {
        this.canvasWidth = window.innerWidth - 30
      }
    },
    // 初始化画布
    init() {
      this.canvas = new fabric.Canvas(