56 lines
1.0 KiB
Vue
56 lines
1.0 KiB
Vue
<template>
|
|
<view>
|
|
<video :style="{width: vWidth + 'px',height: vHeight + 'px'}" :src="src" :poster="poster"></video>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
name:"article-video",
|
|
props: {
|
|
width: {
|
|
type: Number,
|
|
default: 400
|
|
},
|
|
height: {
|
|
type: Number,
|
|
default: 400
|
|
},
|
|
src: {
|
|
type: String,
|
|
default: ''
|
|
},
|
|
poster: {
|
|
type: String,
|
|
default: ''
|
|
}
|
|
},
|
|
data() {
|
|
return {
|
|
vWidth: 400,
|
|
vHeight: 400
|
|
};
|
|
},
|
|
created() {
|
|
console.error("------------------------------- article-video created-------------------------------------------------");
|
|
const maxWidth = uni.upx2px(400)
|
|
const maxHeight = uni.upx2px(400)
|
|
// 获得长边
|
|
const wL = this.width > this.height
|
|
if(wL) {
|
|
this.vWidth = maxWidth
|
|
this.vHeight = this.height/this.width * maxWidth
|
|
}else {
|
|
this.vHeight = maxHeight
|
|
this.vWidth = this.width/this.height * maxHeight
|
|
}
|
|
},
|
|
methods: {
|
|
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
|
|
</style> |