解决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生成图片失败")
            })
        },
原文地址:https://www.cnblogs.com/xiaohuohuai/p/14699938.html