提交 cb3411c9 编写于 作者: H hdx

long-list: 提前请求网络数据

上级 fe2bcdb6
......@@ -56,6 +56,10 @@
type: {
type: String,
default: ''
},
preload: {
type: Boolean,
default: false
}
},
data() {
......@@ -80,19 +84,18 @@
}
}
},
mounted() {
created() {
uni.loadFontFace({
global: false,
family: 'UtsIconsFontFamily',
source: '/static/fonts/icon-star.ttf'
})
if (this.preload) {
this.loadData()
}
},
methods: {
init() {
if (this.dataList.length == 0) {
this.loadData()
}
},
loadData() {
if (this.loading || this.isEnded) {
return
......
......@@ -22,7 +22,7 @@
<swiper class="swiper-view" ref="swiper" :current="swiperIndex" @change="onSwiperChange"
@transition="onSwiperTransition" @animationfinish="onSwiperAnimationfinish">
<swiper-item class="swiper-item" v-for="(item, index) in swiperList" :key="index">
<long-page ref="longPage" :type="item.type"></long-page>
<long-page ref="longPage" :type="item.type" :preload="item.preload"></long-page>
</swiper-item>
</swiper>
</view>
......@@ -40,7 +40,7 @@
type SwiperViewItem = {
type : string,
name : string,
init : Boolean,
preload : Boolean,
}
export default {
......@@ -53,7 +53,8 @@
swiperList: [
{
type: 'UpdatedDate',
name: '最新上架'
name: '最新上架',
preload: true
} as SwiperViewItem,
{
type: 'FreeHot',
......@@ -139,9 +140,9 @@
}
},
initSwiperItemPage(index : Number) {
if (!this.swiperList[index].init) {
this.swiperList[index].init = true;
(this.$refs["longPage"] as ComponentPublicInstance[])[index].$callMethod('init')
if (!this.swiperList[index].preload) {
this.swiperList[index].preload = true;
(this.$refs["longPage"] as ComponentPublicInstance[])[index].$callMethod('loadData')
}
},
updateTabIndicator(left : Number, width : Number) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册