UNPKG

@ctsy/layui-vue

Version:

a component library for Vue 3 base on layui-vue

63 lines (62 loc) 2.46 kB
var __defProp = Object.defineProperty; var __defProps = Object.defineProperties; var __getOwnPropDescs = Object.getOwnPropertyDescriptors; var __getOwnPropSymbols = Object.getOwnPropertySymbols; var __hasOwnProp = Object.prototype.hasOwnProperty; var __propIsEnum = Object.prototype.propertyIsEnumerable; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __spreadValues = (a, b) => { for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]); if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) { if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]); } return a; }; var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); import { defineComponent, useSlots, inject, openBlock, createElementBlock, normalizeClass, unref, createElementVNode, renderSlot, createCommentVNode } from "vue"; const _hoisted_1 = { href: "javascript:void(0)" }; const _hoisted_2 = { key: 0 }; const _hoisted_3 = { key: 1 }; const _hoisted_4 = { key: 2 }; const __default__ = { name: "LayMenuItem" }; const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, __default__), { props: { id: null, title: null }, setup(__props) { const props = __props; const slots = useSlots(); const selectedKey = inject("selectedKey"); const selectHandle = function() { selectedKey.value = props.id; }; return (_ctx, _cache) => { return openBlock(), createElementBlock("li", { class: normalizeClass(["layui-nav-item", [unref(selectedKey) === __props.id ? "layui-this" : ""]]), onClick: _cache[0] || (_cache[0] = ($event) => selectHandle()) }, [ createElementVNode("a", _hoisted_1, [ unref(slots).icon ? (openBlock(), createElementBlock("i", _hoisted_2, [ renderSlot(_ctx.$slots, "icon") ])) : createCommentVNode("", true), unref(slots).title ? (openBlock(), createElementBlock("span", _hoisted_3, [ renderSlot(_ctx.$slots, "title") ])) : (openBlock(), createElementBlock("span", _hoisted_4, [ renderSlot(_ctx.$slots, "default") ])) ]) ], 2); }; } })); _sfc_main.install = (app) => { app.component(_sfc_main.name, _sfc_main); }; export { _sfc_main as default };