feat: convert iconItemSelect component to compositionAPI

This commit is contained in:
IchliebedichZhu 2024-03-08 15:04:30 +00:00
parent 9f95a64582
commit af2e8b389b

View File

@ -18,34 +18,40 @@
</div> </div>
</template> </template>
<script> <script lang="ts" setup>
// //
const NAME = 'icon-item-select' // const NAME = 'icon-item-select'
export default { type TPropData = {
name: NAME, select: boolean,
props: { extraIcon: boolean,
label: { tip: string
default: '', icon?: string
}, }
data: {
required: true, type TProps = {
type: Array, label?: string
}, data: TPropData[]
}, }
emits: ['finish'],
data() { type TEmits = {
return {} (event: 'finish', data: TPropData): void
}, }
methods: {
selectItem(item) { const props = withDefaults(defineProps<TProps>(), {
label: ''
})
const emit = defineEmits<TEmits>()
function selectItem(item: TPropData) {
if (typeof item.select !== 'undefined') { if (typeof item.select !== 'undefined') {
item.select = !item.select item.select = !item.select
} }
this.$emit('finish', item) emit('finish', item)
},
},
} }
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>