UNPKG

always-helper

Version:

前端项目开发中,经常会用到一些工具函数的合集。

2 lines (1 loc) 486 B
import t from"dom-to-image";export default function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"element-image",o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2,i={width:e.clientWidth*o,height:e.clientHeight*o,style:{transform:"scale(".concat(o,")"),transformOrigin:"top left"}};return new Promise((function(o,r){t.toPng(e,i).then((function(t){var e=document.createElement("a");e.download=n,e.href=t,e.click(),o(1)})).catch((function(t){return r(t)}))}))}