【问题标题】:Multiple versions of html2canvas多个版本的 html2canvas
【发布时间】:2019-02-04 14:43:10
【问题描述】:

我将 html2canvas 的版本从 v0.5.0 更新到 v1.0.0,然后某个功能在 iOS 上停止工作。

所以,我想在 iOS 上使用 v0.5.0,在其他设备上使用 v1.0.0。

如何在我的网络应用中同时拥有和使用这两个版本的 html2canvas?

【问题讨论】:

标签: javascript npm html2canvas


【解决方案1】:

尝试编写自定义函数。

 (function (w, d) {
        "use strict";
        var h = d.getElementsByTagName("head")[0],
            s = d.createElement("script");
        w.d3 = null;
        s.src ="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.5.0/html2canvas.min.js";
        s.onload = function () {
            w.d3_3_5_3 = w.d3;
            w.d3 = undefined;
            s = d.createElement("script");
            s.src ="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.5.0/html2canvas.min.js";
            s.onload = function () {
                w.d3_3_5_4 = w.d3;
                w.d3 = undefined;
                s = d.createElement("script");
                s.src = "https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.0.0/html2canvas.min.js";
                s.onload = function () {
                    w.d3_3_5_5 = w.d3;
                    w.d3 = undefined;
                };
                h.appendChild(s);
            };
            h.appendChild(s);
        };
        h.appendChild(s);
    }(window, document));

希望这会有所帮助!

【讨论】:

  • 上面的代码好像是针对d3的。我应该将它应用到“w.html2canvas”而不是“W.d3”,对吗?
  • 试一试。看看函数输出是什么。 d3 只是一个变量。没关系。随意重构。
猜你喜欢
  • 1970-01-01
  • 2020-12-22
  • 2020-09-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-04-07
  • 1970-01-01
  • 2018-09-25
相关资源
最近更新 更多