ant-design-vue/components/input/Search.vue

53 lines
1000 B
Vue
Raw Normal View History

2017-12-06 10:54:20 +00:00
<script>
import Input, { InputProps } from './Input'
import Icon from '../icon'
export default {
name: 'InputSearch',
props: {
...InputProps,
prefixCls: {
default: 'ant-input-search',
type: String,
},
inputPrefixCls: {
default: 'ant-input',
type: String,
},
},
computed: {
},
methods: {
onSearch (e) {
2017-12-07 04:31:12 +00:00
this.$emit('search', this.$refs.input.stateValue)
this.$refs.input.focus()
2017-12-06 10:54:20 +00:00
},
},
render () {
const { inputPrefixCls, prefixCls, ...others } = this.$props
2017-12-07 04:31:12 +00:00
const inputProps = {
props: {
...others,
prefixCls: inputPrefixCls,
},
attrs: this.$attrs,
}
2017-12-06 10:54:20 +00:00
return (
<Input
2017-12-07 04:31:12 +00:00
{...inputProps}
onPressEnter={this.onSearch}
2017-12-06 10:54:20 +00:00
class={prefixCls}
ref='input'
>
<Icon
slot='suffix'
class={`${prefixCls}-icon`}
onClick={this.onSearch}
type='search'
/>
</Input>
)
},
}
</script>