Search.vue 1.1 KB
<template>
  <div class="search">
    <van-search
      v-model="value"
      :placeholder="placeholder"
      @search="onSearch"
      right-icon="search"
      left-icon=""
      v-on:click-right-icon="onSearchRight"
      @input="changeValue"
    />
  </div>
</template>

<script type='text/ecmascript-6'>
export default {
  name: 'Search',
  props: {
    keyword: {
      type: String,
      default: ''
    },
    placeholder: {
      type: String,
      default: '请输入内容搜索'
    }
  },
  data () {
    return {
      value: this.keyword
    }
  },
  mounted () {
  },
  methods: {
    onSearch (e) {
      this.$emit('search', e)
    },
    onSearchRight(){
       this.$emit('rightSearch',this.inputValue)
    },
    changeValue(e){
      this.inputValue = e
      if(!e){
         this.$emit('search', e)
      }
    }
  }
}
</script>

<style scoped lang='scss'>
.van-search {
  padding: 9px 16px;
  height: 50px;
  background: #fff;
  .van-search__content {
    background-color: #fff;
    border: 1px solid #cdd1d4;
    border-radius: 16px;
  }
  .van-cell {
    padding: 5px 16px 5px 0;
  }
}
</style>