let checkImgExists = function(url) {
      return new Promise(function(resolve, reject) {
        let ImgObj = new Image();
        ImgObj.src = url;
        ImgObj.onload = function(res) {
          resolve(res);
        }
        ImgObj.onerror = function(err) {
          reject(err)
        }
      })
    }

    checkImgExists('//www.baidu.com/img/flexible/logo/pc/result.png').then(()=>{
      //success callback
      console.log('有效链接')
    }).catch(()=>{
      //fail callback
      console.log('无效链接')
    })