birdpaper-ui
Version:
一个通用的 vue3 UI组件库。A common vue3 UI component library.
62 lines (61 loc) • 2.17 kB
JavaScript
import { defineComponent, ref, watchEffect, resolveComponent, openBlock, createElementBlock, normalizeClass, createVNode, withCtx, Fragment, renderList, createBlock, createTextVNode, toDisplayString } from "vue";
const __default__ = defineComponent({
name: "PaginationSizes"
});
const _sfc_main = /* @__PURE__ */ defineComponent({
...__default__,
props: {
currentSize: { type: Number, default: "" },
sizesList: { type: Array, default: () => [] },
tmpString: { type: String, default: "" }
},
emits: ["change"],
setup(__props, { emit: emits }) {
const props = __props;
const name = "bp-pagination";
const val = ref(props.currentSize || props.sizesList[0] || 10);
const paramsStr = "{value}";
const list = ref([]);
const onChange = (v) => {
emits("change", v);
};
watchEffect(() => {
for (let i = 0; i < props.sizesList.length; i++) {
const value = props.sizesList[i];
const label = `${props.tmpString.replace(paramsStr, value)}`;
list.value.push({ label, value });
}
});
return (_ctx, _cache) => {
const _component_bp_option = resolveComponent("bp-option");
const _component_bp_select = resolveComponent("bp-select");
return openBlock(), createElementBlock("li", {
class: normalizeClass(`${name}-item ${name}-sizes`)
}, [
createVNode(_component_bp_select, {
modelValue: val.value,
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => val.value = $event),
style: { "width": "100px" },
onChange
}, {
default: withCtx(() => [
(openBlock(true), createElementBlock(Fragment, null, renderList(list.value, (v) => {
return openBlock(), createBlock(_component_bp_option, {
value: v.value
}, {
default: withCtx(() => [
createTextVNode(toDisplayString(v.label), 1)
]),
_: 2
}, 1032, ["value"]);
}), 256))
]),
_: 1
}, 8, ["modelValue"])
], 2);
};
}
});
export {
_sfc_main as default
};