wangkunlong

用的js;

jquery
html2canvas.min.js
 
html中写上海报主体,生成的时候获取最外层类名,
 
把生成的海报弹出来
<!-- 海报图片 -->
            <van-popup class="posterImg_wrap" v-model="showPoster">
                <img :src="posterSrc" alt="">
                <p>长按海报保存</p>
            </van-popup>
// 生成海报
                resultPoster() {
                    let vm = this;
                    vm.$toast.loading({
                        message:"生成中",
                        duration:0,
                    })
                    this.$nextTick(()=>{
                        let target = document.querySelector(\'.haibao_l2\');
                        let width = getComputedStyle(target).width.split(\'px\')[0];
                        let height = getComputedStyle(target).height.split(\'px\')[0];
                        new html2canvas(target, {
                            allowTaint: true,
                            useCORS: true,
                            scrollX: 0,
                            scrollY: 0,
                            width,
                            height,
                            }).then(canvas => {
                            this.posterSrc = canvas.toDataURL("image/jpg");
                        });
                    })
                },
 
碰到无法生成换一下插件版本,或者改一下参数

分类:

技术点:

相关文章:

  • 2021-11-17
  • 2021-11-17
  • 2021-12-09
  • 2021-11-17
  • 2021-11-17
  • 2021-11-17
  • 2021-11-17
  • 2021-12-19
猜你喜欢
  • 2021-11-17
  • 2021-11-17
  • 2021-12-28
  • 2021-12-09
  • 2021-11-17
  • 2021-09-03
相关资源
相似解决方案