提交 a6d45c06 编写于 作者: 雪洛's avatar 雪洛

fix: 修正不符合vue规范的用法

上级 d5c95ab2
......@@ -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<string, Element>
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('直接拿');
}
......
......@@ -34,7 +34,7 @@
components: {},
data() {
return {
$videoContextMap:new Map<string, VideoContext>(),
$videoContextMap: new Map<string, VideoContext>(),
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<string, VideoContext>
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
},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册