深色模式
Utils 工具类
VNodeUtil
isFragment
判断节点是否为 vue 片段(
v-if或v-for等指令片段)
isFragment(node: any): boolean
node: any- 目标节点
isComment
判断节点是否为注释
isComment(node: any): boolean
node: any- 目标节点
isValidElementNode
判断节点是否为有效的元素类型(非 vue 片段或注释)
isValidElementNode(node: any): boolean
node: any- 目标节点
getSlotChildren
获取指定插槽内部子元素节点
getSlotChildren(slots: Slots, name: string): VNode[]
slots: Slots- 组件插槽对象name: string- 目标插槽名称
vue
<template>
<div><slot></slot></div>
</template>
<script setup lang="ts">
import { useSlots } from "vue";
import { VNodeUtil } from "@easyui/element-plus-pro";
const slots = useSlots();
VNodeUtil.isFragment(slots.default());
VNodeUtil.isComment(slots.default());
VNodeUtil.isValidElementNode(slots.default());
VNodeUtil.getSlotChildren(slots, "default");
</script>1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
parseClassStr
将 class 对象值解析为 class 字符串
parseClassStr(classObj: Record<string, boolean>): string
classObj: Record<string, boolean>- 目标 class 对象
parseClassObj
将 class 字符串值解析为 class 对象
parseClassObj(classStr: string): Record<string, boolean>
classStr: string- 目标 class 字符串
parseStyleStr
将 style 对象值解析为 style 字符串
parseStyleStr(styleObj: Record<string, any>): string
styleObj: Record<string, any>- 目标 style 对象
parseStyleObj
将 style 字符串值解析为 style 对象
parseStyleObj(styleStr: string): Record<string, any>
styleStr: string- 目标 style 字符串
vue
<script setup lang="ts">
import { VNodeUtil } from "@easyui/element-plus-pro";
VNodeUtil.parseClassStr({ "example-wrapper": true, "example-border": true });
VNodeUtil.parseClassObj("example-wrapper example-border");
VNodeUtil.parseStyleStr({ width: "50px", height: "50px" });
VNodeUtil.parseStyleObj("width: 50px;height: 50px;");
</script>1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
NumberUtil
parseInt
将目标字符串转换为指定基数的整数
parseInt (str: string, defaultValue: number = 0, radix?: number): number
str: string- 要转换的字符串defaultValue: number- 默认值radix: number- 转换基数
vue
<script setup lang="ts">
import { NumberUtil } from "@easyui/element-plus-pro";
NumberUtil.parseInt(""); // 0
NumberUtil.parseInt("", 1); // 1
NumberUtil.parseInt("10"); // 10
</script>1
2
3
4
5
6
7
2
3
4
5
6
7