【修改】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> <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> </template>
<script> <script>
import { Input } from 'ant-design-vue'
const JINPUT_QUERY_LIKE = 'like'; const JINPUT_QUERY_LIKE = 'like';
const JINPUT_QUERY_NE = 'ne'; const JINPUT_QUERY_NE = 'ne';
const JINPUT_QUERY_GE = 'ge'; //大于等于 const JINPUT_QUERY_GE = 'ge'; //大于等于
const JINPUT_QUERY_LE = 'le'; //小于等于 const JINPUT_QUERY_LE = 'le'; //小于等于
export default { export default {
name: 'JInput', name: 'JInput',
props:{ props:{
value:{ ...Input.props, // 拿到全部外部的参数
type:String, value: {
required:false type: String,
required: false
}, },
type:{ type: {
type:String, type: String,
required:false, required: false,
default:JINPUT_QUERY_LIKE default: JINPUT_QUERY_LIKE
}, },
placeholder:{ placeholder: {
type:String, type: String,
required:false, required: false,
default:'' default: ''
}, },
trim:{ trim: {
type: Boolean, type: Boolean,
required: false, required: false,
default:false default: false
} },
}, },
watch:{ watch:{
value:{ value:{
@@ -38,15 +47,14 @@
this.initVal(); this.initVal();
} }
}, },
// update-begin author:sunjianlei date:20200225 for:当 type 变化的时候重新计算值 ------ // 当 type 变化的时候重新计算值
type() { type() {
this.backValue({ target: { value: this.inputVal } }) this.backValue({ target: { value: this.inputVal } })
}, },
// update-end author:sunjianlei date:20200225 for:当 type 变化的时候重新计算值 ------
}, },
model: { model: {
prop: 'value', prop: 'value',
event: 'change' event: 'input_change'
}, },
data(){ data(){
return { return {
@@ -100,7 +108,7 @@
break; break;
default: default:
} }
this.$emit("change",text) this.$emit('input_change', text);
} }
} }
} }