+
95
-

js如何直接下载canvas照片?

请问js如何直接下载canvas照片?

网友回复

+
15
-
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>BFW NEW PAGE</title>


</head>
<body>
    <canvas id="canvas" width="400" height="400"></canvas>
    <div>
        <button id="save">保存</button>

        <script type="text/javascript">
            var arr = [{
                locations: [[0,
                    0],
                    [200,
                        200],
                    [0,
                        400]],
                color: "red"
            },
                {
                    locations: [[0,
                        0],
                        [400,
                            0],
                        [200,
                            200]],
                    color: "orange"
                },
                {
                    locations: [[0,
                        400],
                        [100,
                            300],
                        [200,
                            400]],
                    color: "yellow"
                },
                {
                    locations: [[100,
                        300],
                        [200,
                            200],
                        [300,
                            300],
                        [200,
                            400]],
                    color: "green"
                },
                {
                    locations: [[300,
                        100],
                        [200,
             ...

点击查看剩余70%

我知道答案,我要回答