支持直接使用icon属性配置按钮图标

This commit is contained in:
鄢鹏权 2022-01-26 08:30:08 +00:00 committed by Gitee
parent 5c79b2b9ba
commit 43b9d2a2e3
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -17,6 +17,7 @@ export interface LayButtonProps {
disabled?: boolean | string;
loading?: boolean | string;
nativeType?: "button" | "submit" | "reset";
icon?: string;
}
const props = withDefaults(defineProps<LayButtonProps>(), {
@ -25,6 +26,7 @@ const props = withDefaults(defineProps<LayButtonProps>(), {
loading: false,
disabled: false,
nativeType: "button",
icon: "",
});
const emit = defineEmits(["click"]);
@ -58,6 +60,7 @@ const classes = computed(() => {
:type="nativeType"
@click="onClick"
>
<i v-if="icon" :class="'layui-icon ' + icon"></i>
<i
v-if="loading"
class="layui-icon layui-icon-loading-one layui-anim layui-anim-rotate layui-anim-loop"