[新增] select 组件
This commit is contained in:
@@ -1,14 +1,31 @@
|
||||
<template>
|
||||
<dd :value="value">
|
||||
<slot></slot>
|
||||
<dd :value="value" @click="selectHandle" :class="[selectItem.value === value?'layui-this':'']">
|
||||
{{label}}
|
||||
</dd>
|
||||
</template>
|
||||
|
||||
<script setup name="LaySelectOption" lang="ts">
|
||||
import { defineProps } from 'vue'
|
||||
import { SelectItem } from '../type'
|
||||
import { defineProps, inject } from 'vue'
|
||||
|
||||
const props =
|
||||
defineProps<{
|
||||
value?: string
|
||||
label?: string
|
||||
}>()
|
||||
|
||||
const selectItem = inject("selectItem") as SelectItem
|
||||
|
||||
const selectHandle = function(){
|
||||
selectItem.value = props.value
|
||||
selectItem.label = props.label
|
||||
}
|
||||
|
||||
// init selected
|
||||
|
||||
if(selectItem.value === props.value) {
|
||||
selectItem.value = props.value
|
||||
selectItem.label = props.label
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user