如何解决在将 src 绑定到 Image 组件后获取错误大小的图像 [Nativescript]
当我绑定我的 src 属性时,我得到了错误大小的图像。所以逻辑是:在加载图像时,我将占位符图像作为源,加载图像后,我不得不用 actula 图像更改占位符。所以逻辑是有效的,但我的占位符图像显示的大小错误,尽管如果帖子不包含任何图像,我会传递相同的占位符,在这种情况下它会很棒
可能有什么问题?
<template>
<transition name="fade">
<Image ref="image" :src="src" stretch="aspectFit" class="img" />
</transition>
</template>
<script lang="ts">
import { Component,Prop,Watch} from 'vue-property-decorator'
import Vue from 'nativescript-vue'
@Component<LazyImage>({
name: 'LazyImage',mounted(): void {
this.load()
}
})
export class LazyImage extends Vue {
@Prop({type: String,required : true})
private readonly imageSrc: string
public imageRef: any | null = null
public get isLoading(): boolean {
return !this.imageRef ? true : (!!this.imageRef.isLoading)
}
public get src (): string {
return this.isLoading ? '~/images/placeholder.png' : this.imageSrc
}
public load(): void {
this.imageRef = this.$refs.image.nativeView
}
}
export default LazyImage
</script>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。