mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-12 11:55:26 +08:00
a2f7d6d062
closes vueComponent/ant-design-vue#5765 Add `compatConfig: { MODE: 3 }` to all component definitions to signal to `@vue/compat` not to use any Vue 2 compatibility features.
53 lines
1.1 KiB
Vue
53 lines
1.1 KiB
Vue
import { defineComponent, ref, withDirectives } from 'vue';
|
|
import antInput from './antInputDirective';
|
|
import PropTypes from './vue-types';
|
|
const BaseInput = defineComponent({
|
|
compatConfig: { MODE: 3 },
|
|
props: {
|
|
value: PropTypes.string.def(''),
|
|
},
|
|
emits: ['change', 'input'],
|
|
setup(_p, { emit }) {
|
|
const inputRef = ref(null);
|
|
const handleChange = (e: Event) => {
|
|
const { composing } = e.target as any;
|
|
if ((e as any).isComposing || composing) {
|
|
emit('input', e);
|
|
} else {
|
|
emit('input', e);
|
|
emit('change', e);
|
|
}
|
|
};
|
|
return {
|
|
inputRef,
|
|
focus: () => {
|
|
if (inputRef.value) {
|
|
inputRef.value.focus();
|
|
}
|
|
},
|
|
blur: () => {
|
|
if (inputRef.value) {
|
|
inputRef.value.blur();
|
|
}
|
|
},
|
|
handleChange,
|
|
};
|
|
},
|
|
render() {
|
|
return withDirectives(
|
|
(
|
|
<input
|
|
{...this.$props}
|
|
{...this.$attrs}
|
|
onInput={this.handleChange}
|
|
onChange={this.handleChange}
|
|
ref="inputRef"
|
|
/>
|
|
) as any,
|
|
[[antInput]],
|
|
);
|
|
},
|
|
});
|
|
|
|
export default BaseInput;
|