判断是否可用,若图片是相对路径会转换为绝对路径
图片地址
回调函数
const relativeUrl: string = 'images/picture.jpg';checkAndConvertImage(relativeUrl, (absoluteUrl: string, isAvailable: boolean) => {if (isAvailable) { console.log('图片地址可用: ' + absoluteUrl); } else { console.log('图片地址不可用: ' + absoluteUrl); }}); 复制
const relativeUrl: string = 'images/picture.jpg';checkAndConvertImage(relativeUrl, (absoluteUrl: string, isAvailable: boolean) => {if (isAvailable) { console.log('图片地址可用: ' + absoluteUrl); } else { console.log('图片地址不可用: ' + absoluteUrl); }});
判断是否可用,若图片是相对路径会转换为绝对路径