1、首先通過(guò)data定義三個(gè)變量,一個(gè)代表滾動(dòng)條滾動(dòng)的距離,一個(gè)代表div距頂部的距離;
2、通過(guò)監(jiān)聽(tīng)scroll來(lái)判斷滾動(dòng)條滾動(dòng)的距離是否大于div距頂部的距離;
3、頁(yè)面銷(xiāo)毀的時(shí)候要清除點(diǎn)scoll事件;

handleScroll()?{
??????this.scrollTop?=?window.pageYOffset?||?document.documentElement.scrollTop?||?document.body.scrollTop?||?document.scrollingElement.scrollTop?||?0;
??????if?(this.scrollTop?>?this.tabOffsetTop)?{
????????this.barFixed?=?true;
??????}?else?{
????????this.barFixed?=?false;
??????}
????},