在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML5  HTML/ vue用這個方法翻頁 怎么改善 mounted會影響全部頁面?

vue用這個方法翻頁 怎么改善 mounted會影響全部頁面?

mounted(){

        window.addEventListener('scroll',this.menu);
       // setTimeout(()=>{
        this.a=document.body.scrollHeight||document.documentElement.scrollHeight
            this.c =  document.documentElement.clientHeight;
      //  },200)


    },
    
     methods: {
        menu() {

            //this.a=document.body.scrollHeight||document.documentElement.scrollHeight;
            this.b=document.body.scrollTop||document.documentElement.scrollTop;
            //通過判斷滾動條的top位置與可視網(wǎng)頁之和與整個網(wǎng)頁的高度是否相等來決定是否加載內(nèi)容;
            if(this.b+this.c>=this.a){
                setTimeout(()=>{
                    this.$router.push('/intelligenceb' );
                },100)
            }
            console.log(this.a,this.b, this.c)


        }
    },
回答
編輯回答
念初

你這個事件是加載window上的,vue切換頁面并不是真的跳轉(zhuǎn)重新加載,當(dāng)然每個頁面都生效
該頁面beforeDestroy時清理掉事件即可

2018年5月30日 11:09