From cb3411c9de0e387435574dc84665ff5226b47bfa Mon Sep 17 00:00:00 2001 From: hdx Date: Sat, 26 Aug 2023 15:01:01 +0800 Subject: [PATCH] =?UTF-8?q?long-list:=20=E6=8F=90=E5=89=8D=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E7=BD=91=E7=BB=9C=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/template/long-list/long-list-page.uvue | 15 +++++++++------ pages/template/long-list/long-list.uvue | 13 +++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/pages/template/long-list/long-list-page.uvue b/pages/template/long-list/long-list-page.uvue index f6fd5051..777cbc7e 100644 --- a/pages/template/long-list/long-list-page.uvue +++ b/pages/template/long-list/long-list-page.uvue @@ -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 diff --git a/pages/template/long-list/long-list.uvue b/pages/template/long-list/long-list.uvue index aa3a02dd..03d01fac 100644 --- a/pages/template/long-list/long-list.uvue +++ b/pages/template/long-list/long-list.uvue @@ -22,7 +22,7 @@ - + @@ -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) { -- GitLab