emis-sapp/components/tpx-image/tpx-image.vue
2023-12-12 15:00:16 +08:00

71 lines
987 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 'aspectFit' // aspectFit | widthFix
}
},
scale: {
default () {
return [1, 1] // 宽高比
}
},
},
data() {
return {
loadFlag: false,
imageHeight: 0,
}
},
created() {
},
onHide() {
},
destroyed() {},
methods: {
bindload: function(res) {
this.loadFlag = true
this.imageHeight = res.detail.height
}
}
}
</script>
<style scoped lang="scss">
</style>