This commit is contained in:
lnn19986213 2024-02-02 15:09:17 +08:00
parent 29d02046e9
commit d34f05a3ca
1 changed files with 11 additions and 2 deletions

View File

@ -9,7 +9,7 @@
<template>
<div class="sc-icon-select">
<el-input v-model="defaultValue" :prefix-icon="defaultValue||'none'" :placeholder="placeholder" :clearable="clearable" :disabled="disabled">
<el-input v-model="defaultValue" :prefix-icon="defaultValue||'none'" :placeholder="placeholder" :clearable="clearable" :disabled="disabled" @clear="onClear" @change="onChange">
<template #append><el-button icon="el-icon-more" @click="open"></el-button></template>
</el-input>
<el-dialog title="图标选择器" v-model="dialogVisible" :width="780" destroy-on-close>
@ -42,7 +42,7 @@
props: {
modelValue: { type: String, default: "" },
placeholder: { type: String, default: "请输入或者选择图标" },
clearable: { type: Boolean, default: false },
clearable: { type: Boolean, default: true },
disabled: { type: Boolean, default: false },
},
data() {
@ -75,12 +75,21 @@
this.dialogVisible = true
},
selectIcon(e){
console.log(111,e)
if(e.target.tagName != 'I'){
return false
}
this.defaultValue = e.target.className
this.dialogVisible = false
this.$emit('update:modelValue', this.defaultValue);
},
onClear() {
this.$emit('update:modelValue', this.defaultValue);
},
onChange() {
if(this.defaultValue == ''){
this.$emit('update:modelValue', this.defaultValue);
}
}
}
}