在jsplumb中使用html2canvas + svgToCanvas 将svg图片以及canvas生成缩略图并用于用户在界面下载和上传后台

本文介绍了如何在jsplumb画图后,利用html2canvas和svgToCanvas库将SVG图片及Canvas转换为缩略图。这些缩略图可用于用户在界面上的下载操作,同时也能上传到后台。
摘要由CSDN通过智能技术生成

使用jsplumb框架画图
使用html2canvas + svgToCanvas 将svg图片以及canvas生成缩略图并用于用户在界面下载和上传后台

// 导入utils.js文件,导入html2canvas包
import utils from '../../utils/util'
import html2canvas from 'html2canvas'
…………


    downloadPicture () {
    // 用户生成图片用于本地下载
      this.designLoading = true
      if (!this.checkJpg()) {
   
        this.designLoading = false
        return
      }
      this.$refs.designCanvas.unselectCurrent() // 取消所有节点的选中关闭右侧编辑框
      this.createJpg().then((response) => {
   
        this.$Message.success('缩略图生成成功')
        this.designLoading = false
        this.pictureVisible = true
      }).catch(() => {
   
        this.designLoading = false
        this.$Message.error('缩略图生成失败请重试')
      })
    },
    downLoadFlowPicture () {
    // 用户下载缩略图
      utils.downLoadFlowPicture(this.graphId, this.htmlUrl, this.graphName)
    },
    cancelDownLoadFlowPicture () {
   
      this.pictureVisible = false
    },
    async createJpg () {
    // 生成缩略图
      this.designLoading = true
      const create = this
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值