feat: 输入框组件数据联动添加回车键触发

main
wu.jian2 2 years ago
parent 53e11cdc61
commit c5653f4113

@ -9,13 +9,14 @@
</span> </span>
<el-input <el-input
:id="`el-input-${config.code}`" :id="`el-input-${config.code}`"
v-model="config.customize.value" v-model="value"
type="text" type="text"
resize="both" resize="both"
class="input" class="input"
:placeholder="config.customize.placeholderStyle.placeholder" :placeholder="config.customize.placeholderStyle.placeholder"
:style="{ backgroundColor: config.customize.backgroundStyle.backgroundColor }" :style="{ backgroundColor: config.customize.backgroundStyle.backgroundColor }"
@input="handleInput" @input="handleInput"
@keyup.enter.native="keyupEnter"
> >
<i <i
v-if="config.customize.icon.position === 'left' && config.customize.icon.name" v-if="config.customize.icon.position === 'left' && config.customize.icon.name"
@ -50,6 +51,7 @@ export default {
}, },
data () { data () {
return { return {
value: '',
timer: null timer: null
} }
}, },
@ -63,6 +65,7 @@ export default {
}, },
mounted () { mounted () {
this.chartInit() this.chartInit()
this.changeStyle(this.config)
}, },
beforeDestroy () { beforeDestroy () {
// //
@ -97,9 +100,13 @@ export default {
handleInput (val) { handleInput (val) {
// //
this.debounce(() => { this.debounce(() => {
console.log('val', val)
this.linkage({ [this.config.code]: val }) this.linkage({ [this.config.code]: val })
}) })
}, },
keyupEnter () {
this.linkage({ [this.config.code]: this.value })
},
debounce (fn, delay = 500) { debounce (fn, delay = 500) {
clearTimeout(this.timer) clearTimeout(this.timer)
this.timer = setTimeout(() => { this.timer = setTimeout(() => {

Loading…
Cancel
Save