ant-design-vue/components/auto-complete/InputElement.vue

37 lines
774 B
Vue
Raw Normal View History

2018-02-27 11:08:49 +00:00
<script>
2018-02-28 11:07:04 +00:00
import PropTypes from '../_util/vue-types'
2018-02-27 11:08:49 +00:00
import { cloneElement } from '../_util/vnode'
export default {
2018-02-28 11:07:04 +00:00
props: {
value: PropTypes.any,
disabled: PropTypes.bool,
},
2018-02-27 11:08:49 +00:00
methods: {
focus () {
const ele = this.$refs.ele
ele.focus ? ele.focus() : this.$el.focus()
},
blur () {
const ele = this.$refs.ele
ele.blur ? ele.blur() : this.$el.blur()
},
},
render () {
2018-02-28 11:07:04 +00:00
const { $slots = {}, $listeners = {}, $props = {}, $attrs = {}} = this
const value = $props.value === undefined ? '' : $props.value
return cloneElement($slots.default[0], {
2018-02-27 11:08:49 +00:00
domProps: {
2018-02-28 11:07:04 +00:00
value,
2018-02-27 11:08:49 +00:00
},
2018-02-28 11:07:04 +00:00
props: $props,
2018-02-27 11:08:49 +00:00
on: $listeners,
2018-02-28 11:07:04 +00:00
attrs: { ...$attrs, value },
2018-02-27 11:08:49 +00:00
ref: 'ele',
})
},
}
</script>