@wfrog/vc
Version:
`自用` 的基于 `element-plus` 二次封装的 `vue3` 组件库。追求在业务场景中,尽可能使用更少的代码量来实现需求。 因此在组件封装上,以 `方便` 为主,打包仅 `esm` 模式。
68 lines (65 loc) • 2.77 kB
JavaScript
import './index.css'
// vue-script:D:\project\_my\vc\src\components\easy-pagination\index.vue?type=script
import { defineComponent as _defineComponent } from "vue";
import { unref as _unref, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, withCtx as _withCtx, createVNode as _createVNode, normalizeClass as _normalizeClass, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue";
import { computed } from "vue";
import { ElButton } from "element-plus";
var easy_pagination_default = /* @__PURE__ */ _defineComponent({
__name: "index",
props: {
size: { type: String, default: "small" },
prevText: { type: String, default: "\u4E0A\u4E00\u9875" },
nextText: { type: String, default: "\u4E0B\u4E00\u9875" },
currentPage: { type: Number, default: 1 },
haveNext: { type: Boolean, default: false }
},
emits: ["currentChange", "update:currentPage", "prevClick", "nextClick"],
setup(__props, { emit: emits }) {
const props = __props;
const havePrev = computed(() => props.currentPage > 1);
const 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) => {
return _openBlock(), _createElementBlock("div", {
class: _normalizeClass(_ctx.$style.main)
}, [
_createVNode(_unref(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(_unref(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);
};
}
});
// vue-style:D:\project\_my\vc\src\components\easy-pagination\index.vue?type=style&index=0&isModule=true&isNameImport=true
var easy_pagination_default2 = { main: "_main_1y8do_1" };
// src/components/easy-pagination/index.vue
var cssModules = {};
easy_pagination_default.__cssModules = cssModules = {};
cssModules["$style"] = easy_pagination_default2;
var easy_pagination_default3 = easy_pagination_default;
export {
easy_pagination_default3 as default
};