1.報(bào)錯(cuò)一
[渲染層錯(cuò)誤] [Component] : current 屬性無效,請修改 current 值(env: Windows,mp,1.06.2307250; lib: 2.24.0)
這個(gè)是頁面使用輪播組件時(shí),沒有添加current屬性,添加上就可以了,但是添加后,小程序在手機(jī)上鎖屏(有時(shí)候要等幾分鐘)重新打開時(shí),頁面瘋狂卡頓,輪播文章來源:http://www.zghlxwxcb.cn/news/detail-781100.html
<swiper class="swiper02" autoplay='true' current="{{currentidx}}" bindchange="swiperChange" circular='true' interval='2000' >
<block wx:for="{{swiperdata}}" wx:for-item="item" wx:key="id" wx:for-index="index">
<swiper-item>
<image class="swiper" mode="widthFix" src="{{item.imageUrl}}" ></image>
</swiper-item>
</block>
</swiper>
2.造成頁面輪播瘋狂卡頓,極速輪播
data{
swiperdata:{},
currentidx:'0'
}
swiperChange(e){
let current = e.detail.current
let source = e.detail.source
// 直接賦值時(shí)造成輪播瘋狂卡頓,極速輪播,(錯(cuò)誤的)
this.setData({
currentidx: current,
})
// 用下面的瘋狂卡頓就沒有了(正確的)
if (source == 'autoplay' || source == 'touch') {
//根據(jù)官方 source 來進(jìn)行判斷swiper的change事件是通過什么來觸發(fā)的,autoplay是自動(dòng)輪播。touch是用戶手動(dòng)滑動(dòng)。其他的就是未知問題。抖動(dòng)問題主要由于未知問題引起的,所以做了限制,只有在自動(dòng)輪播和用戶主動(dòng)觸發(fā)才去改變current值,達(dá)到規(guī)避了抖動(dòng)bug
this.setData({
currentidx: current,
})
}
}
3.卡頓效果,頁面一直處于兩個(gè)頁面切換效果,消息輪播頁處于不上不下狀態(tài)
文章來源地址http://www.zghlxwxcb.cn/news/detail-781100.html
到了這里,關(guān)于小程序使用swiper時(shí)報(bào)錯(cuò), [Component] <swiper>: current 屬性無效,請修改 current 值或者頁面卡頓,瘋狂輪播的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!