From a6d45c0666085c0e19aabcd7f3da1920599bff77 Mon Sep 17 00:00:00 2001 From: wangyaqi Date: Fri, 24 Nov 2023 12:05:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=E4=B8=8D=E7=AC=A6?= =?UTF-8?q?=E5=90=88vue=E8=A7=84=E8=8C=83=E7=9A=84=E7=94=A8=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/template/drop-card/card/card.uvue | 7 ++++--- .../swiper-vertical-video.uvue | 13 +++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/pages/template/drop-card/card/card.uvue b/pages/template/drop-card/card/card.uvue index 56e15b81..d4cb9b85 100644 --- a/pages/template/drop-card/card/card.uvue +++ b/pages/template/drop-card/card/card.uvue @@ -79,11 +79,12 @@ this.setElementStyle('card','transform', 'scale('+(0.9 + 0.05 * _index)+')') }, // 工具方法,用于快速设置 Element 的 style - setElementStyle(refName:string,propertyName : string, propertyStyle : any) : void { - let element : Element | null = this.$elementMap.get(refName) + setElementStyle(refName:string,propertyName : string, propertyStyle : any) : void { + const elementMap = this.$data['$elementMap'] as Map + let element : Element | null = elementMap[refName] if(element == null){ element = this.$refs[refName] as Element; - this.$elementMap.set(refName,element) + elementMap[refName] = element }else{ // console.log('直接拿'); } diff --git a/pages/template/swiper-vertical-video/swiper-vertical-video.uvue b/pages/template/swiper-vertical-video/swiper-vertical-video.uvue index 63270640..0bb568af 100644 --- a/pages/template/swiper-vertical-video/swiper-vertical-video.uvue +++ b/pages/template/swiper-vertical-video/swiper-vertical-video.uvue @@ -34,7 +34,7 @@ components: {}, data() { return { - $videoContextMap:new Map(), + $videoContextMap: new Map(), list: [] as ListItem[], visibleList: [] as ListItem[],// 提高性能 可见的只有3个 current: 0 as number, @@ -42,7 +42,7 @@ state: ["unPlay", "unPlay", "unPlay"] as string[] } }, - beforeCreate() { + created() { this.list = this.getData() this.visibleList = this.list.slice(0, 3) }, @@ -73,7 +73,7 @@ this.visibleList = visibleList } - this.state.forEach((val : string, index : number) => { + this.state.forEach((_ : string, index : number) => { if (index === current) { this.doPlay(current) } else { @@ -110,11 +110,12 @@ onLoadstart(index : number) { console.error("onLoadstart video" + index ); }, - getVideoContext(index : number) : VideoContext{ - let videoContext : VideoContext | null = this.$videoContextMap.get('video-'+index) + getVideoContext(index : number) : VideoContext { + const videoContextMap = this.$data['$videoContextMap'] as Map + let videoContext : VideoContext | null = videoContextMap['video-'+index] if(videoContext == null){ videoContext = uni.createVideoContext('video-'+index, this) as VideoContext - this.$videoContextMap.set('video-'+index,videoContext) + videoContextMap['video-'+index] = videoContext } return videoContext }, -- GitLab