@cqmcui/cqmcui
Version:
轻量级移动端 Vue2、Vue3 组件库(支持小程序开发)
77 lines (76 loc) • 2.8 kB
JavaScript
import { toRefs, computed, openBlock, createElementBlock, createElementVNode, normalizeStyle, renderSlot, Fragment, createCommentVNode, toDisplayString } from "vue";
import { c as createComponent } from "./component-81a4c1d0.js";
import { _ as _export_sfc } from "./_plugin-vue_export-helper-cc2b3d55.js";
import "../locale/lang";
const { componentName, create, translate } = createComponent("empty");
const defaultStatus = {
empty: "https://static-ftcms.jd.com/p/files/61a9e3183985005b3958672b.png",
error: "https://ftcms.jd.com/p/files/61a9e33ee7dcdbcc0ce62736.png",
network: "https://static-ftcms.jd.com/p/files/61a9e31de7dcdbcc0ce62734.png"
};
const _sfc_main = create({
props: {
image: {
type: String,
default: "empty"
//默认empty
},
imageSize: {
type: [Number, String],
// 图片大小,正方形
default: ""
},
description: {
type: String,
// 文字区
default: ""
}
},
setup(props) {
const { image, imageSize } = toRefs(props);
const imgStyle = computed(() => {
if (!imageSize.value) {
return "";
}
if (typeof imageSize.value === "number") {
return `width:${imageSize.value}px;height:${imageSize.value}px`;
}
return `width:${imageSize.value};height:${imageSize.value}`;
});
const isHttpUrl = image.value.startsWith("https://") || image.value.startsWith("http://") || image.value.startsWith("//");
const imageUrl = isHttpUrl ? image.value : defaultStatus[image.value];
return {
imageUrl,
imgStyle,
translate
};
}
});
const _hoisted_1 = { class: "cqmc-empty" };
const _hoisted_2 = ["src"];
const _hoisted_3 = {
key: 1,
class: "cqmc-empty__description"
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createElementBlock("view", _hoisted_1, [
createElementVNode("view", {
class: "cqmc-empty__box",
style: normalizeStyle(_ctx.imgStyle)
}, [
_ctx.$slots.image ? renderSlot(_ctx.$slots, "image", { key: 0 }) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
_ctx.imageUrl ? (openBlock(), createElementBlock("img", {
key: 0,
class: "cqmc-empty__box--img",
src: _ctx.imageUrl
}, null, 8, _hoisted_2)) : createCommentVNode("", true)
], 64))
], 4),
_ctx.$slots.description ? renderSlot(_ctx.$slots, "description", { key: 0 }) : (openBlock(), createElementBlock("view", _hoisted_3, toDisplayString(_ctx.description || _ctx.translate("noData")), 1)),
_ctx.$slots.default ? renderSlot(_ctx.$slots, "default", { key: 2 }) : createCommentVNode("", true)
]);
}
const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
export {
index as default
};