diff --git a/pages/template/drop-card/card/card.uvue b/pages/template/drop-card/card/card.uvue index 56e15b81a640d286ec7559e8ceb5d79b89a1f80b..d4cb9b856657edfe704d4e394edca94593ac9cd7 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 63270640325ab94ed3713269d82c6e3385ad6e6d..0bb568af220791fa22fc3a570a534f0c22aa92fc 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 },