嘗試過使用網友說的API接口獲取 找到的都是失效了
暫時就使用這種辦法獲取 如果有好的方法望評論告知 謝謝
<img :ng-src="'http://'+list.url+'/favicon.ico'" :src="'http://'+list.url+'/favicon.ico'" onerror="this.src='https://s2.ax1x.com/2020/02/02/1YRugf.png'"
alt="" width="14" height="14" style="display: block;float:left;margin-top:3px;" ng-show="item.littleIcon" class="">
list.url是網址數據 動態
onerror="this.src='https://s2.ax1x.com/2020/02/02/1YRugf.png'"
原理:利用拼接的方式獲取根路徑下的favicon.ico
但是有的網址沒有存放在跟路徑下 所有就用到了 onerror標簽 表示加載失敗就執行
onerror定義和用法
onerror 事件會在文檔或圖像加載過程中發生錯誤時被觸發。
在裝載文檔或圖像的過程中如果發生了錯誤,就會調用該事件句柄。
this.src='https://s2.ax1x.com/2020/02/02/1YRugf.png'
第一個ico是獲取成功的 第二個是獲取失敗的 就賦值
https://s2.ax1x.com/2020/02/02/1YRugf.png(存在圖床里面 自己隨便定義圖片ico 或者事件)