美文网首页
vue 滑动,顶部显示当前时间

vue 滑动,顶部显示当前时间

作者: 宇少_e010 | 来源:发表于2020-08-10 16:05 被阅读0次
<div class='content' v-for="(item,index) in data">
              <div class='time_box_text' v-if='item.time==true&&index!=0'>{{item.ctime*1000 | formatitem}}</div>
              <div class='content_text' ref="tter">
                <router-link :to="'/article/'+item.id+'?'+'categoryId'+'='+item.cagegoryId">
                  <div class='title'>
                    <span v-show="item.tag!=''" class='lab' v-for="label in item.tag" :style='{background:label.color}'>
                      {{label.tag_name}}
                    </span>
                    {{item.title}}
                  </div>
                  <div class='detail'>
                    <span v-html='item.brief.replace(/[\r\n]/g,"<br/>")'></span>
                  </div>
                </router-link>
                <router-link :to="'/Specialse/'+item.cagegoryId">
                  <div class="data">
                    <ul>
                      <li>{{item.ctime*1000 | formatDate}}</li>
                      <!-- <li v-if="item.unlock!=1">{{item.unlock_num}}人解锁</li> -->
                      <li v-if="item.unlock==1">免费</li>
                    </ul>
                    <div class='research_box'>
                      <div class="research">{{item.cagegoryname}}</div><img src="../../images/F134@2x.png" alt="">
            </div>
                    </div>
                </router-link>
              </div>
            </div>
  mounted() {
    window.addEventListener("scroll", this.menu);
  },
  for (let i = 0; i < res.data.length; i++) {
            this.time = this.time.concat(
              formatDatess(res.data[i].ctime * 1000)
            );
            for (var j = 0; j < this.time.length; j++) {
              if (this.time[j] == this.time[j - 1]) {
                res.data[i].time = false;
              } else {
                res.data[i].time = true;
              }
            }
          }
 menu(el) {
      function isinvewportofone(el) {
        var scrolls =  window.innerHeight ||   document.documentElement.clientHeight ||  document.body.clientHeight;
        const offsetTop = el.offsetTop;
        const scrollTop = document.scrollingElement.scrollTop;
        const top = offsetTop - scrollTop;
        return top <= scrolls - scrolls;
      }
      var _this = this;
      this.$refs.tter.filter(function(e, i) {
        if (isinvewportofone(e)) {
          _this.nwedatas = _this.data[i].ctime;
        }
      });
    },

相关文章

网友评论

      本文标题:vue 滑动,顶部显示当前时间

      本文链接:https://www.haomeiwen.com/subject/aoejdktx.html