修复 button disabled 状态下 click 仍然触发的问题
This commit is contained in:
parent
683ca7c267
commit
a1f8afc4b5
@ -122,7 +122,7 @@ export default {
|
|||||||
<lay-button type="normal" radius>百搭按钮</lay-button>
|
<lay-button type="normal" radius>百搭按钮</lay-button>
|
||||||
<lay-button type="warm" radius>暖色按钮</lay-button>
|
<lay-button type="warm" radius>暖色按钮</lay-button>
|
||||||
<lay-button type="danger" radius>警告按钮</lay-button>
|
<lay-button type="danger" radius>警告按钮</lay-button>
|
||||||
<lay-button type="disabled" radius>禁用按钮</lay-button>
|
<lay-button @click="onClick" disabled radius>禁用按钮</lay-button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@ -131,7 +131,12 @@ import { ref } from 'vue'
|
|||||||
export default {
|
export default {
|
||||||
setup() {
|
setup() {
|
||||||
|
|
||||||
|
const onClick = () => {
|
||||||
|
console.log("click event");
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
onClick
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,14 @@ const props = withDefaults(defineProps<LayButtonProps>(), {
|
|||||||
nativeType: "button",
|
nativeType: "button",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits(["click"]);
|
||||||
|
|
||||||
|
const onClick = (event : any) => {
|
||||||
|
if(!props.disabled) {
|
||||||
|
emit("click", event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const classes = computed(() => {
|
const classes = computed(() => {
|
||||||
return [
|
return [
|
||||||
props.type ? `layui-btn-${props.type}` : "",
|
props.type ? `layui-btn-${props.type}` : "",
|
||||||
@ -48,6 +56,7 @@ const classes = computed(() => {
|
|||||||
classes,
|
classes,
|
||||||
]"
|
]"
|
||||||
:type="nativeType"
|
:type="nativeType"
|
||||||
|
@click="onClick"
|
||||||
>
|
>
|
||||||
<i
|
<i
|
||||||
v-if="loading"
|
v-if="loading"
|
||||||
|
Loading…
Reference in New Issue
Block a user