强大的canvas库Fabric.js基础图解

转载自: https://juejin.cn/post/7026941253845516324 简介Fabric.js 简介 Fabric.js 是一个功能强大且操作简单的 Javascript HTML5 canvas 工具库。 如果你需要...

canvas
44 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3Z">'); } }, onLoadSuccess: (el) => { if (el) { $(el).find('.loading-wrap').remove(); } }, onLoadFailure: (el) => { if (el) { $(el).find('.loading-wrap svg').remove(); $(el).find('.loading-wrap').append(''); $(el).find('.loading-wrap').addClass('error'); } }, request: (el, url, callback, onFailure) => { let retryTimes = 3; utils.onLoading(el); function req() { return new Promise((resolve, reject) => { let status = 0; // 0 等待 1 完成 2 超时 let timer = setTimeout(() => { if (status === 0) { status = 2; timer = null; reject('请求超时'); if (retryTimes == 0) { onFailure(); } } }, 5000); fetch(url).then(function(response) { if (status !== 2) { clearTimeout(timer); resolve(response); timer = null; status = 1; } if (response.ok) { return response.json(); } throw new Error('Network response was not ok.'); }).then(function(data) { retryTimes = 0; utils.onLoadSuccess(el); callback(data); }).catch(function(error) { if (retryTimes > 0) { retryTimes -= 1; setTimeout(() => { req(); }, 5000); } else { utils.onLoadFailure(el); onFailure(); } }); }); } req(); }, };