yufile 发表于 2021-10-29 09:05:33

指示器hover问题

// 使用了 自定义分页器,但是需要使用hover分页器切换图片,浏览器没有缓存的时候第一次加载,会导致hover分页器无法使用原因是// `bullets`没有长度,不知道各位大神有没有解决办法
renderBullet: (index, className) => {
return `<span class="${className}">
             <div>
               <span class="title">${manipulatingFont(this.setBanner[index].title, 30)}</span>
               <span class="info">${this.setBanner[index].description ? manipulatingFont(this.setBanner[index].description, 40) : ''}</span>
             </div>
             <span class="hui"></span>
          </span>`;
}methods: {etJurisdiction(as) {
setTimeout(() => {
    console.log(1)
    for (let i = 0; i < as.bullets.length; i++) {
      console.log(2)
      const that = this;
      as.bullets[i].index = i
      as.bullets[i].onmouseover = function() {
      that.mySwiper.slideTo(this.index + 1);
      that.mySwiper.autoplay.stop()
      };
      as.bullets[i].onmouseleave = function() {
      that.mySwiper.autoplay.start()
      };
      as.bullets[i].onclick = function() {
      if (that.setBanner[this.index].url) {
          window.location.href = that.setBanner[this.index].url
      }
      }
    }
}, 1000)
}}

stylish 发表于 2021-11-2 16:02:10

组件初始化数据前添加loading,template里面swiper组件上添加v-if="!loading"
页: [1]
查看完整版本: 指示器hover问题