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

54 lines
1005 B
React
Raw Normal View History

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