收藏
回答

swiper组件swiper-item动态设置属性导致样式错乱-webview模式下

框架类型 问题类型 终端类型 微信版本 基础库版本
小程序 Bug 微信iOS客户端 8.0.59 3.8.3

webview渲染模式下,动态的设置swiper-item的style会导致样式错乱,但是未找到任何官方说明不能设置动态样式,以上代码片段模拟了我遇到的问题,通过 如下方式

let index = 0;
let colors = ['#f09','#80f','#603'];
let timer = setInterval(()=>{
  this.setData({
    [`background[${index}].d`]:colors[index],
    index: index+1
  });
  index++;
  if(index >= this.data.background.length) {
    clearInterval(timer);
  }
},2000);

每隔两秒设置一次swiper-item上定义的 样式-background-color 将导致 swiper-item样式错乱。

回答关注问题邀请回答
收藏
登录 后发表内容