UNPKG

always-helper

Version:

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

2 lines (1 loc) 613 B
import t from"dom-to-image";export default function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;"string"==typeof e&&(e=document.querySelector(e));var r={width:e.clientWidth*n,height:e.clientHeight*n,style:{transform:"scale(".concat(n,")"),transformOrigin:"top left"}};return new Promise((function(n,o){t.toBlob(e,r).then((function(t){try{var e=new ClipboardItem({"image/png":t});navigator.clipboard.write([e]).then((function(){return n()})).catch((function(t){return o(t.message||"暂不支持复制")}))}catch(t){o(t.message||"暂不支持复制")}})).catch((function(t){return o(t)}))}))}