isTool
kingcwt2023-10-26前端tool func typescript
/**
* @description 判断链接是否有效
* @param link
* @returns
*/
export const isItAValidLink = (link: string | undefined) => {
return new Promise()<[boolean, string | Event]>((resolve, reject) => {
const imgObj = new Image();
imgObj.src = link || "";
imgObj.onload = (res) => {
resolve([true, res]);
};
imgObj.onerror = (err) => {
resolve([false, err]);
};
});
};