1.swiper
如果要指定切换到某张swiper-item,需要调用change来修改current的值,
<swiper class="swiper" autoplay indicator-dots :current="currentIndex" @change="onChangeSwiper">
<swiper-item>1<swiper-item>
</swiper>
data() {
return: {
currentIndex: 0
}
}
//事件
methods: {
onChangeSwiper(e) {
this.currentIndex = e.detail.current
},
// 业务处理,比如tab下有多个swiper,切换时要把swiper置为第一张
onTapMeeting() {
this.currentIndex = 0
}
}
问题2:如果在swiper-item发生语法错误,比如:解析失败则会报$$什么什么错误
2.使用v-for时指定key值不能为undefined,值必须有效(哪怕用index都行),否则当前item值取不到,如
// 如果下面的item里面没有a属性值则传的item是undefined
<view
class="img-item"
:class="topListClass"
v-for="item in topList"
:key="item.a"
@tap="onTapHotMore(item)"
>
<image mode="aspectFit" :src="fileServer(item.imageId)" />
</view>
onTapHotMore(item) {
console.log(item); // item为undefined
}
3.在mixi里不要定义filters然后在页面上使用,否则会让你意想不到的错误,比如:goods.imageId为undefined然后使用fileServer()来格式化则整个页面使用了这个方法都执行不了,连v-if都阻止不了