html2canvas 未定义

Nik*_*lbv 6 canvas html2canvas

我正在使用 angularjs 和 php 开发我的项目,需要保存一个将在最后生成的证书,带有内容的证书是动态创建的,但right click->save as由于它不是图像而无法创建,所以我为此使用了画布,但它似乎没有帮助。

我将它包含在我的 HTML 文件的 head 标签中

<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.5.0-alpha1/html2canvas.js">
</script>
Run Code Online (Sandbox Code Playgroud)

但它仍然说“未定义 html2canvas”

我的 HTML 代码:

<div class="userCertificate" id="html-content-holder">
    <div class="secondborder">
        <img src="images/ISRO_Logo.png" height="80px" alt="ISRO_LOGO" style="text-align: left">
        <div class="content">
            <h2 style="color:#f47216">NATIONAL REMOTE SENSING CENTRE</h2>
            <br>
            <h1>Certificate Of Appreciation</h1>
            <br>
            <p>This certificate is awarded to </p>
            <h1><span class="Name"> {{studentname}} </span></h1>
            <p>from <span class="collegeName">{{collegeName}}</span> for succesfully qualifying online quiz exam with score of <span class="collegeName">{{marks}}</span> %</p>
            <p> conducted on 6/06/2019</p>
        </div>
        <img src="images/stamp.PNG" height="80px" alt="ISRO_LOGO" style="float: right;margin-top: 80px;margin-right: 30px">
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

<input type='button' id='but_screenshot' value='Take screenshot' onclick='screenshot();'>

我的Javascript代码:

function screenshot() {
            html2canvas(document.getElementById('userCertificate')).then(function(canvas) {
                document.body.appendChild(canvas);
            });
        }
Run Code Online (Sandbox Code Playgroud)