Scenario: Larger images load very slowly, and there will be a long white screen, which makes the user experience poor.
Solution : Once you enter the page, before the picture is loaded successfully, perform loading...; the @load event will be triggered after the picture is loaded;
<template>
<view class="">
<image @load="loadImg($event)" src="../static/image.jpg" mode="widthFix" />
</view>
</template>
<script>
export default {
data () {
return {
}
},
onShow () {
//开启加载
uni.showLoading({
title: '加载中...',
mask: true
})
},
methods: {
// 此方法会在图片加载完成后触发
loadImg (e) {
uni.hideLoading()
console.log('图片信息', e)
},
},
}
</script>
<style>
</style>