perf: 发布 0.2.3 版本
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
<template>
|
||||
<dd
|
||||
:value="value"
|
||||
:class="[selectItem.value === value ? 'layui-this' : '',disabled ? 'layui-disabled':'']"
|
||||
:class="[
|
||||
selectItem.value === value ? 'layui-this' : '',
|
||||
disabled ? 'layui-disabled' : '',
|
||||
]"
|
||||
@click="selectHandle"
|
||||
>
|
||||
{{ label }}
|
||||
@@ -10,19 +13,24 @@
|
||||
|
||||
<script setup name="LaySelectOption" lang="ts">
|
||||
import { SelectItem } from '../type'
|
||||
import { defineProps, inject, Ref } from 'vue'
|
||||
import { defineProps, inject, onMounted, Ref } from 'vue'
|
||||
|
||||
const props = defineProps<{
|
||||
value?: string
|
||||
label?: string
|
||||
disabled?: boolean
|
||||
}>()
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
value: string
|
||||
label: string
|
||||
disabled?: boolean | string
|
||||
}>(),
|
||||
{
|
||||
disabled: false,
|
||||
}
|
||||
)
|
||||
|
||||
const selectItem = inject('selectItem') as SelectItem
|
||||
const openState = inject('openState') as Ref<boolean>
|
||||
|
||||
const selectHandle = function () {
|
||||
if(props.disabled) {
|
||||
if (props.disabled) {
|
||||
return
|
||||
}
|
||||
openState.value = false
|
||||
@@ -31,8 +39,10 @@ const selectHandle = function () {
|
||||
}
|
||||
|
||||
// init selected
|
||||
if (selectItem.value === props.value) {
|
||||
selectItem.value = props.value
|
||||
selectItem.label = props.label
|
||||
}
|
||||
onMounted(() => {
|
||||
if (selectItem.value === props.value) {
|
||||
selectItem.value = props.value
|
||||
selectItem.label = props.label
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user