save.onclick = function() {
var url = canvas.toDataURL("image/png");
var a = document.createElement("a");
document.body.appendChild(a);
a.href = url;
a.download = "我的画儿";
a.target = "_blank";
a.click();
};
There is a download button save in canvas panel, click on it you can download and save to a local canvas.
a property tag
- download
this attribute instructs the browser to download a URL instead of navigating to it, so the user will be prompted to save it as a local file. Value as a filling file name of the property. - href
the URL of limited to those based Web (HTTP) document, you can use any browser that supports the protocol. For example, it works properly in most browsersfile:
, ftp: and mailto: There tel :. - target
- _self: The default value, in the current page loads.
- _blank: a new window opens.
Usually click on a link usually the default is to open this page in a browser, which is not what we want. I think there is any good way to load additional tab pages of it?
- Press and hold the
ctrl
button click on the link will open in a new tab - Middle mouse button or scroll wheel click on the link will open in a new tab
- Press and hold the
shift
button click on the link will open in a new window
Reproduced in: https: //www.jianshu.com/p/7f6756fd3ddd