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

Merge pull request !22 from 鄢鹏权/N/A
This commit is contained in:
就眠儀式 2022-01-26 08:30:53 +00:00 committed by Gitee
commit 52595132ad
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; disabled?: boolean | string;
loading?: boolean | string; loading?: boolean | string;
nativeType?: "button" | "submit" | "reset"; nativeType?: "button" | "submit" | "reset";
icon?: string;
} }
const props = withDefaults(defineProps<LayButtonProps>(), { const props = withDefaults(defineProps<LayButtonProps>(), {
@ -25,6 +26,7 @@ const props = withDefaults(defineProps<LayButtonProps>(), {
loading: false, loading: false,
disabled: false, disabled: false,
nativeType: "button", nativeType: "button",
icon: "",
}); });
const emit = defineEmits(["click"]); const emit = defineEmits(["click"]);
@ -58,6 +60,7 @@ const classes = computed(() => {
:type="nativeType" :type="nativeType"
@click="onClick" @click="onClick"
> >
<i v-if="icon" :class="'layui-icon ' + icon"></i>
<i <i
v-if="loading" v-if="loading"
class="layui-icon layui-icon-loading-one layui-anim layui-anim-rotate layui-anim-loop" class="layui-icon layui-icon-loading-one layui-anim layui-anim-rotate layui-anim-loop"