71 lines
989 B
Vue
71 lines
989 B
Vue
<template>
|
|
<image :src="src" :mode="mode" :hidden="!loadFlag" @load="bindload" :style="cusStyle"></image>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
computed: {
|
|
cusStyle() {
|
|
let s = ``
|
|
if(this.height) {
|
|
s+= `height:${this.height}rpx;`
|
|
}
|
|
if(this.width) {
|
|
s+= `width:${this.width}rpx;`
|
|
}
|
|
return s
|
|
},
|
|
},
|
|
props: {
|
|
src: {
|
|
default () {
|
|
return ''
|
|
}
|
|
},
|
|
height: {
|
|
default () {
|
|
return ''
|
|
}
|
|
},
|
|
width: {
|
|
default () {
|
|
return ''
|
|
}
|
|
},
|
|
mode: {
|
|
default () {
|
|
return 'aspectFill' // aspectFill | widthFix
|
|
}
|
|
},
|
|
scale: {
|
|
default () {
|
|
return [1, 1] // 宽高比
|
|
}
|
|
},
|
|
},
|
|
data() {
|
|
return {
|
|
loadFlag: false,
|
|
imageHeight: 0,
|
|
}
|
|
},
|
|
created() {
|
|
|
|
},
|
|
onHide() {
|
|
|
|
},
|
|
unmounted() {},
|
|
|
|
methods: {
|
|
bindload: function(res) {
|
|
this.loadFlag = true
|
|
this.imageHeight = res.detail.height
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
|
|
</style> |