mirror of
https://github.com/palxiao/poster-design.git
synced 2025-07-15 16:02:19 +08:00
feat: convert iconItemSelect component to compositionAPI
This commit is contained in:
parent
9f95a64582
commit
af2e8b389b
@ -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: Array,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
emits: ['finish'],
|
|
||||||
data() {
|
|
||||||
return {}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
selectItem(item) {
|
|
||||||
if (typeof item.select !== 'undefined') {
|
|
||||||
item.select = !item.select
|
|
||||||
}
|
|
||||||
this.$emit('finish', item)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type TProps = {
|
||||||
|
label?: string
|
||||||
|
data: TPropData[]
|
||||||
|
}
|
||||||
|
|
||||||
|
type TEmits = {
|
||||||
|
(event: 'finish', data: TPropData): void
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<TProps>(), {
|
||||||
|
label: ''
|
||||||
|
})
|
||||||
|
|
||||||
|
const emit = defineEmits<TEmits>()
|
||||||
|
|
||||||
|
|
||||||
|
function selectItem(item: TPropData) {
|
||||||
|
if (typeof item.select !== 'undefined') {
|
||||||
|
item.select = !item.select
|
||||||
|
}
|
||||||
|
emit('finish', item)
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user