vuux
Version:
Vue3 Nuxt3 Nuxt4 组件库
33 lines (32 loc) • 787 B
JavaScript
import { ref as c, computed as n, onMounted as u, nextTick as d } from "vue";
import { ImagePreview as h } from "../../../ImagePreview/index.mjs";
const w = (e, i) => {
const a = c(!1), o = () => {
a.value = !0;
}, r = n(() => ({
width: e.width ? e.width + "px" : "auto",
height: e.height ? e.height + "px" : "auto",
objectFit: e.fit,
borderRadius: e.border + "px"
})), s = (t) => {
e.preview && h(t);
};
return u(async () => {
await d(() => {
const t = new Image();
t.src = e.src, t.onload = () => {
setTimeout(() => {
i.value && i.value.classList.add("is-success");
}, 200);
};
});
}), {
isError: a,
styles: r,
handleImagePreview: s,
onError: o
};
};
export {
w as useImage
};