zoukankan      html  css  js  c++  java
  • 解决html2canvas在苹果手机上不调用问题

    解决方案一

    1.首先将 package.json 中的 html2canvas 版本降低为【1.0.0-rc.4】
    版本降低方法
    首先移除 html2canvas 【npm uninstall html2canvas】
    然后安装指定版本 【npm install --save html2canvas@1.0.0-rc.4】

    解决方案二

    因为这是html2canvas插件的bug,这里有修改源码后的地址:

    https://github.com/Liusq-Cindy/html2Canvas

    import html2canvas from "../../utils/html2canvas";
    
     //获取详情
            getinfo(hid,sign){
                this.loading=true
                this.$apiRequest('details', {
                    "hid":Number(hid),
                    "sign":sign
                }).then(res => {
                    this.info = res.data
                   // alert(res.data.avatar)
                   this.qrcode = this.changeUrl(res.data.qrcode)
                    this.$nextTick(()=>{
                    if(res.data.poster_type==="0"){
                         //alert("请求接口")
                        this.$nextTick(()=>{
                            
                            setTimeout(()=>{
                                let poster = document.getElementById("haibaoone");
                                this.createImg(poster)
                            },1000)  
                        })
                    }else if(res.data.poster_type==="1"){
                        //alert("请求接口")
                        this.$nextTick(()=>{
                            setTimeout(()=>{
                                let poster = document.getElementById("haibaotwo");
                                this.createImg(poster)
                            },1000) 
                        })
                    }
                    
                        
                    })
                   
                })
            },
            createImg(dom) {
                (window.html2canvas || html2canvas)(dom, {
                    dpi: 80,
                    useCORS: true,
                    scale: 4,
                    async: true,
                    //  dom.offsetWidth,
                    // height: dom.offsetHeight
                    x: this.getActuralPosition(dom).left + parseInt(this.getScrollWidth()/2),
                    y: this.getActuralPosition(dom).top,
                }).then(canvas => {
                    this.imgSrc = canvas.toDataURL("image/jpeg");
                    this.showdiv = false
                    this.loading=false
                    //alert("s生成图片成功")
                })
                .catch(err => {
                    this.loading=false
                    //alert("s生成图片失败")
                })
            },
  • 相关阅读:
    字符串加密和解密的常类
    vs2013中使用nuget下载cefsharp winform包
    序列积第m小元素 二分答案优化
    贪心 park
    struct结构体 重载运算符
    最小生成树kruskal 知识点讲解+模板
    c++快读与快输模板
    MZOJ #82 总统竞选
    MZOJ #83 位运算
    MZOJ #81 最小得分和
  • 原文地址:https://www.cnblogs.com/xiaohuohuai/p/14699938.html
Copyright © 2011-2022 走看看