【修改】JInput组件进行改造,可传递所有props给a-input,也可以监听到a-input的全部事件

This commit is contained in:
zer0Black
2021-03-25 16:42:08 +08:00
parent abfe801623
commit 982310046a
+28 -20
View File
@@ -1,35 +1,44 @@
<template>
<a-input :placeholder="placeholder" :value="inputVal" @input="backValue"></a-input>
<a-input :placeholder="placeholder"
:value="inputVal"
@input="backValue"
v-bind="$props"
v-on="$listeners"
></a-input>
</template>
<script>
import { Input } from 'ant-design-vue'
const JINPUT_QUERY_LIKE = 'like';
const JINPUT_QUERY_NE = 'ne';
const JINPUT_QUERY_GE = 'ge'; //大于等于
const JINPUT_QUERY_LE = 'le'; //小于等于
export default {
name: 'JInput',
props:{
value:{
type:String,
required:false
...Input.props, // 拿到全部外部的参数
value: {
type: String,
required: false
},
type:{
type:String,
required:false,
default:JINPUT_QUERY_LIKE
type: {
type: String,
required: false,
default: JINPUT_QUERY_LIKE
},
placeholder:{
type:String,
required:false,
default:''
placeholder: {
type: String,
required: false,
default: ''
},
trim:{
trim: {
type: Boolean,
required: false,
default:false
}
default: false
},
},
watch:{
value:{
@@ -38,15 +47,14 @@
this.initVal();
}
},
// update-begin author:sunjianlei date:20200225 for:当 type 变化的时候重新计算值 ------
// 当 type 变化的时候重新计算值
type() {
this.backValue({ target: { value: this.inputVal } })
},
// update-end author:sunjianlei date:20200225 for:当 type 变化的时候重新计算值 ------
},
model: {
prop: 'value',
event: 'change'
event: 'input_change'
},
data(){
return {
@@ -100,7 +108,7 @@
break;
default:
}
this.$emit("change",text)
this.$emit('input_change', text);
}
}
}