UNPKG

yuang-framework-ui-pc

Version:

yuang-framework-ui-pc Library

74 lines (73 loc) 2.32 kB
"use strict"; const vue = require("vue"); const _sfc_main = vue.defineComponent({ name: "CropperPreview", props: { /** 组件宽度 */ previewWidth: { type: Number, required: true }, /** 裁剪比例 */ aspectRatio: Number }, setup() { const rootRef = vue.ref(null); const getPreviews = () => { if (!rootRef.value) { return; } return rootRef.value.querySelectorAll(".ele-cropper-preview"); }; return { rootRef, getPreviews }; } }); const _export_sfc = (sfc, props) => { const target = sfc.__vccOpts || sfc; for (const [key, val] of props) { target[key] = val; } return target; }; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return vue.openBlock(), vue.createElementBlock("div", { ref: "rootRef", class: "ele-cropper-previews", style: vue.normalizeStyle({ width: `${_ctx.previewWidth + 14}px` }) }, [ vue.createElementVNode("div", { class: "ele-cropper-preview", style: vue.normalizeStyle({ width: `${_ctx.previewWidth}px`, height: `${_ctx.previewWidth / (_ctx.aspectRatio || 1)}px`, marginTop: "0px" }) }, null, 4), _ctx.aspectRatio === 1 ? (vue.openBlock(), vue.createElementBlock("div", { key: 0, class: "ele-cropper-preview is-circle", style: vue.normalizeStyle({ width: `${_ctx.previewWidth}px`, height: `${_ctx.previewWidth / _ctx.aspectRatio}px` }) }, null, 4)) : _ctx.aspectRatio ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 1 }, [ vue.createElementVNode("div", { class: "ele-cropper-preview", style: vue.normalizeStyle({ width: `${_ctx.previewWidth}px`, height: `${(_ctx.previewWidth / 3 * 2 - 10) / _ctx.aspectRatio}px` }) }, null, 4), vue.createElementVNode("div", { class: "ele-cropper-preview", style: vue.normalizeStyle({ width: `${_ctx.previewWidth}px`, height: `${_ctx.previewWidth / 3 / _ctx.aspectRatio}px`, marginLeft: "10px" }) }, null, 4) ], 64)) : vue.createCommentVNode("", true) ], 4); } const cropperPreview = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]); module.exports = cropperPreview;