UNPKG

@wfrog/vc

Version:

vue3 组件库 vc

75 lines (69 loc) 2.59 kB
import './index.css' import '../../chunk/E_WRn0OP.mjs'; import { E as ElButton } from '../../chunk/BT7IBuxS.mjs'; import { defineComponent, computed, createElementBlock, openBlock, normalizeClass, createVNode, unref, withCtx, createTextVNode, toDisplayString } from 'vue'; import { _ as _export_sfc } from '../../chunk/pcqpp-6-.mjs'; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "easy-pagination", props: { size: { default: "small" }, prevText: { default: "上一页" }, nextText: { default: "下一页" }, currentPage: { default: 1 }, haveNext: { type: Boolean, default: false } }, emits: ["currentChange", "update:currentPage", "prevClick", "nextClick"], setup(__props, { emit: __emit }) { const props = __props; const emits = __emit; const havePrev = computed(() => props.currentPage > 1); function handlePageChange(p) { let currentPage = props.currentPage + p; currentPage = currentPage > 0 ? currentPage : 1; emits("update:currentPage", currentPage); emits("currentChange", currentPage); p < 0 && emits("prevClick", currentPage); p > 0 && emits("nextClick", currentPage); } return (_ctx, _cache) => { const _component_ElButton = ElButton; return openBlock(), createElementBlock("div", { class: normalizeClass(_ctx.$style.main) }, [ createVNode(_component_ElButton, { size: __props.size, disabled: !unref(havePrev), onClick: _cache[0] || (_cache[0] = () => handlePageChange(-1)) }, { default: withCtx(() => [ createTextVNode(toDisplayString(__props.prevText), 1) ]), _: 1 }, 8, ["size", "disabled"]), createVNode(_component_ElButton, { size: __props.size, disabled: !__props.haveNext, onClick: _cache[1] || (_cache[1] = () => handlePageChange(1)) }, { default: withCtx(() => [ createTextVNode(toDisplayString(__props.nextText), 1) ]), _: 1 }, 8, ["size", "disabled"]) ], 2); }; } }); /* unplugin-vue-components disabled */const main = "_main_1y8do_1"; const style0 = { main: main }; const cssModules = { "$style": style0 }; const Component = /* @__PURE__ */ _export_sfc(_sfc_main, [["__cssModules", cssModules]]); const __vite_glob_0_15 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({ __proto__: null, default: Component }, Symbol.toStringTag, { value: 'Module' })); export { Component as C, __vite_glob_0_15 as _ };