老师检查一下有问题

来源:1-4 Vue项目详情页 - 实现Header渐隐渐显效果

精慕门5221908

2020-10-03 16:10:19

<template>

  <div>

    <router-link tag="div"

     to="/" 

     class="header-ads"

     v-show="showAbs">

      <div class="iconfont ads-icon">&#xe685;</div>

    </router-link>

    <div class="header-fixed" v-show="!showAbs" :style="opacityStyle">

      <router-link to="./">

        <div class="iconfont header-fixed-back">&#xe685;</div>

      </router-link>

      景点详情

    </div>

  </div>

</template>


<script>

export default {

  name: "DetailHeader",

  data() {

      return {

          showAbs:true,

          opacityStyle:{

              opacity:0

          }

      }

  },

  methods:{

      handleScrole () {

          const top = document.documentElement.scrollTop

          if(top > 60 ){

              let opacity = top /140

              opacity = opacity > 1 ? 1 : opacity

              this.opacityStyle = {opacity}

              this.showAbs = false

          }else{

              this.showAbs = true

          }

      }

  },

  activated () {

      window.addEventListener('scroll', this.handleScrole)

  }

};

</script>


<style lang="stylus" scoped>

@import "~styles/varibles.styl";

.header-ads

    position absolute

    left .2rem

    top .2rem

    width .8rem

    height .8rem

    line-height .8rem

    text-align center

    border-radius .4rem

    background rgba(0, 0, 0, .8)

    .ads-icon

        font-size .4rem

.header-fixed

    position fixed

    top 0

    left 0

    right 0

    height $headerheight

    line-height $headerheight

    text-align center

    color #fff

    background :$bgcolor

    font-size .32rem

    .header-fixed-back

        position absolute

        top 0

        left 0

        width .64rem

        font-size .4rem

        color #fff

</style>



写回答

2回答

好帮手慕星星

2020-10-07

同学你好,自己能够解决问题是很棒的哦!

继续加油,祝学习愉快~

0

精慕门5221908

提问者

2020-10-03

已解决,麻烦老师了

0

0 学习 · 10739 问题

查看课程