@opensig/opendesign
Version:
<p align="center"><img src="../docs/public/opendesign-logo-light.png"/></p> <h1 align="center">opendesign</h1> <p align="center">一个 Vue 3 组件库</p> <p align="center"><b>皮肤可定制,使用 TypeScript</b></p>
67 lines (66 loc) • 1.9 kB
JavaScript
import { defineComponent, ref, createElementBlock, openBlock, createElementVNode } from "vue";
const _hoisted_1 = { class: "o-upload-select-input" };
const _hoisted_2 = ["accept", "disabled"];
const _hoisted_3 = ["accept", "disabled"];
const _sfc_main = /* @__PURE__ */ defineComponent({
__name: "InputSelect",
props: {
accept: {},
disabled: { type: Boolean }
},
emits: ["selected"],
setup(__props, { expose: __expose, emit: __emit }) {
const props = __props;
const emits = __emit;
const inputRef = ref(null);
const multipleInputRef = ref(null);
const onInputChange = function(e) {
const target = e.target;
const files = target.files;
if (files && files.length > 0) {
emits("selected", files);
}
target.value = "";
};
const select = (multiple) => {
var _a, _b;
if (props.disabled) {
return;
}
if (multiple) {
(_a = multipleInputRef.value) == null ? void 0 : _a.click();
} else {
(_b = inputRef.value) == null ? void 0 : _b.click();
}
};
__expose({
select
});
return (_ctx, _cache) => {
return openBlock(), createElementBlock("div", _hoisted_1, [
createElementVNode("input", {
ref_key: "multipleInputRef",
ref: multipleInputRef,
type: "file",
class: "o-upload-input",
multiple: "",
accept: props.accept,
disabled: props.disabled,
onChange: onInputChange
}, null, 40, _hoisted_2),
createElementVNode("input", {
ref_key: "inputRef",
ref: inputRef,
type: "file",
class: "o-upload-input",
accept: props.accept,
disabled: props.disabled,
onChange: onInputChange
}, null, 40, _hoisted_3)
]);
};
}
});
export {
_sfc_main as default
};