推荐关注
Meteor
JSLint - a JavaScript code quality tool
jsFiddle
D3.js
WebStorm
推荐书目
JavaScript 权威指南第 5 版
Closure: The Definitive Guide
keroppi

用 document.createElement 创建的 canvas 能导出 base64 图像吗?

  •  
  •   keroppi · Aug 7, 2020 · 3022 views
    This topic created in 2107 days ago, the information mentioned may be changed or developed.
    用 toDataURL() 导出 反复测试好像不可以,图片都是空白的,有什么办法吗?
    5 replies    2020-08-07 13:49:31 +08:00
    jimliang
        1
    jimliang  
       Aug 7, 2020
    你是不是用了跨域图片?
    chnwillliu
        2
    chnwillliu  
       Aug 7, 2020 via Android   ❤️ 1
    把元素 attach 到文档里了吗?不想显示在页面上的话就要用离屏 canvas,https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas
    Latin
        3
    Latin  
       Aug 7, 2020
    加上跨域处理,除非图片加了防盗链
    keroppi
        4
    keroppi  
    OP
       Aug 7, 2020
    @chnwillliu 谢谢,看了文档,这就是我想要的,不过就是兼容性差了点 safari 不支持
    keroppi
        5
    keroppi  
    OP
       Aug 7, 2020
    @jimliang
    @Latin

    不是跨域的问题
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4629 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 01:03 · PVG 09:03 · LAX 18:03 · JFK 21:03
    ♥ Do have faith in what you're doing.