<template>
  <div class="uif-option-search">
    <UInput :placeholder="placeholder" v-model="keyword" @u-change="handleChange" @enter="handleSearch"></UInput>
  </div>
</template>
<script>
import UInput from '@uif/hq/src/components/input'
import {debounce} from '@uif/hq/src/utils/pipe'

export default {
  components: {UInput},
  props: {
    size: {
      type: String
    },
    placeholder: {
      type: String,
      default: '请输入关键字搜索'
    }
  },
  data () {
    return {
      keyword: '',
      handleChange: debounce(() => this.handleSearch(), 500)
    }
  },
  watch: {
  },
  methods: {
    // 搜索事件
    handleSearch (e) {
      this.$emit('search', this.keyword)
    }
  }
}
</script>
