使用uni-app遇到的问题总结

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都阻止不了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值