Screenshot 屏幕截图

... 2021-7-29 Less than 1 minute

# Screenshot 屏幕截图

Tips

2.1.1+

<!-- 导入需要的包 (一定要放到index.html中的head标签里)-->
<script src="https://cdn.staticfile.net/html2canvas/0.5.0-beta4/html2canvas.min.js"></script>
1
2
<el-button @click="handleOk"
                 type="primary"
                 icon="el-icon-camera"
                 >意见反馈</el-button>
  <el-dialog modal-append-to-body
            append-to-body
            title="意见反馈"
            top="50px"
            :visible.sync="box"
            width="60%">
  <el-input type="textarea"
            placeholder="请告诉我们遇到的问题或建议"
            v-model="form.text"></el-input>
     <br />
     <br />
  <div v-loading="flag"
        element-loading-text="正在截取屏幕数据">
    <img :src="form.img"
          width="100%" />
  </div>
  <span slot="footer" >
    <el-button type="primary"
                icon="el-icon-check"
                @click="handleSubmit">提 交</el-button>
  </span>
</el-dialog>
<script>
export default {
    data () {
      return {
        box: false,
        form: {
          img: '',
          text: ''
        }
      }
    },
    computed: {
      flag () {
        return this.form.img;
      }
    },
    methods: {
      handleOk () {
        this.form = {
          img: '',
          text: ''
        }
        this.$Screenshot(document.querySelector("#app")).then(canvas => {
          this.form.img = canvas.toDataURL("image/jpeg", 0.8);
        });
        this.box = true;
      }
    }
}
</script>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
Expand Copy
Last update: August 14, 2024 15:38
Contributors: smallwei
您正在浏览基于 Vue 2.x 的 Avue 文档; 点击这里 查看 Vue 3.x 的升级版本