提交 0fb61a2e 编写于 作者: Q qiang

fix: image load

上级 c694bc4c
......@@ -106,7 +106,7 @@ function useImageState(rootRef: Ref<HTMLElement | null>, props: ImageProps) {
})
const state = reactive({
rootEl: rootRef,
src: computed(() => getRealPath(props.src)),
src: computed(() => (props.src ? getRealPath(props.src) : '')),
origWidth: 0,
origHeight: 0,
origStyle: { width: '', height: '' },
......@@ -138,7 +138,11 @@ function useImageLoader(
const loadImage = (src: string) => {
if (!src) {
resetImage()
resetSize()
state.origWidth = 0
state.origHeight = 0
state.imgSrc = ''
// 与微信小程序保持一致,保留之前样式
// resetSize()
return
}
if (!img) {
......@@ -215,6 +219,9 @@ function useImageSize(
rootEl.style[names[1] as 'height' | 'width'] =
fixNumber(value / ratio) + 'px'
}
if (__PLATFORM__ === 'app') {
window.dispatchEvent(new CustomEvent('updateview'))
}
}
const resetSize = () => {
const { style } = rootRef.value!
......
......@@ -5908,7 +5908,7 @@ function useImageState(rootRef, props2) {
});
const state = reactive({
rootEl: rootRef,
src: computed(() => getRealPath(props2.src)),
src: computed(() => props2.src ? getRealPath(props2.src) : ""),
origWidth: 0,
origHeight: 0,
origStyle: {
......@@ -5935,7 +5935,9 @@ function useImageLoader(state, {
const loadImage = (src) => {
if (!src) {
resetImage();
resetSize();
state.origWidth = 0;
state.origHeight = 0;
state.imgSrc = "";
return;
}
if (!img) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册