日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > HTML >内容正文

HTML

前端预加载gif

發布時間:2023/12/9 HTML 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 前端预加载gif 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

內容描述待補充~

<!-- 頭部gif背景圖 S --><div id="Header":style="`height:${H};`"class="Header"><img id="headersBgGif"data-up="https://f2.kkmh.com/20200417tm.gif"src="https://f2.kkmh.com/20200424tm.gif" style="display: none;"><img id="header_bg_img"src="~assets/img/pd/contest/header_bg.png" style="display: block;"></div><!-- 頭部gif背景圖 E --> initHeight(){const _this = this;//1598[設計圖高度]*(headers.offsetWidth[獲取的實際寬度] / 2560[設計圖的寬度]) = 實際高度const Diffuse = document.getElementById('Diffuse');const W = Diffuse ? Diffuse.offsetWidth : 0;const num = W / 2560 > 1 ? 1 : W / 2560;this.setDiffuseRatio( num ); //存儲到vux 中的寬度實際比率this.H = Math.ceil( 1598 * this.diffuseRatio ) + 'px';console.log('h', this.H)// debugger;const headersBgGif = document.getElementById('headersBgGif');const headersBgImg = document.getElementById('header_bg_img');//判斷圖片是否加載完成if(!headersBgGif){return false;}let imgs = new Image;imgs.src = headersBgGif.src;imgs.onload = function() {if (headersBgImg) {headersBgGif.parentNode.removeChild(headersBgImg);}headersBgGif.style.display = 'block'};imgs.onerror = function(){console.error('頭部gif 加載失敗,請刷新重試!');}},

總結

以上是生活随笔為你收集整理的前端预加载gif的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。