1
This commit is contained in:
3
package/component/es/tabItem/index.js
Normal file
3
package/component/es/tabItem/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
import "../badge/index2.js";
|
||||
export { c as default } from "./index2.js";
|
||||
import "vue";
|
||||
48
package/component/es/tabItem/index2.js
Normal file
48
package/component/es/tabItem/index2.js
Normal file
@@ -0,0 +1,48 @@
|
||||
import { w as withInstall } from "../badge/index2.js";
|
||||
import { defineComponent, getCurrentInstance, useSlots, inject, reactive, onBeforeUnmount, openBlock, createElementBlock, normalizeClass, unref, renderSlot } from "vue";
|
||||
const TabInjectKey = Symbol("layuiTab");
|
||||
const __default__ = {
|
||||
name: "LayTabItem"
|
||||
};
|
||||
const _sfc_main = defineComponent({
|
||||
...__default__,
|
||||
props: {
|
||||
id: null,
|
||||
title: null,
|
||||
icon: null,
|
||||
closable: { type: [Boolean, String], default: true }
|
||||
},
|
||||
setup(__props) {
|
||||
var _a;
|
||||
const props = __props;
|
||||
const instance = getCurrentInstance();
|
||||
const slots = useSlots();
|
||||
const active = inject("active");
|
||||
const tabsCtx = inject(TabInjectKey, {});
|
||||
const data = reactive({
|
||||
id: props.id,
|
||||
title: props.title,
|
||||
icon: props.icon,
|
||||
closable: props.closable,
|
||||
slots
|
||||
});
|
||||
if (instance == null ? void 0 : instance.uid) {
|
||||
(_a = tabsCtx.addItem) == null ? void 0 : _a.call(tabsCtx, props.id, data);
|
||||
}
|
||||
onBeforeUnmount(() => {
|
||||
var _a2;
|
||||
if (instance == null ? void 0 : instance.uid) {
|
||||
(_a2 = tabsCtx.removeItem) == null ? void 0 : _a2.call(tabsCtx, props.id);
|
||||
}
|
||||
});
|
||||
return (_ctx, _cache) => {
|
||||
return openBlock(), createElementBlock("div", {
|
||||
class: normalizeClass(["layui-tab-item", [unref(active) === __props.id ? "layui-show" : ""]])
|
||||
}, [
|
||||
renderSlot(_ctx.$slots, "default")
|
||||
], 2);
|
||||
};
|
||||
}
|
||||
});
|
||||
const component = withInstall(_sfc_main);
|
||||
export { TabInjectKey as T, _sfc_main as _, component as c };
|
||||
Reference in New Issue
Block a user