iview/src/components/transfer/search.vue

49 lines
1.2 KiB
Vue
Raw Normal View History

<template>
<div :class="prefixCls">
<i-input
2017-03-07 15:06:38 +08:00
v-model="currentQuery"
size="small"
:icon="icon"
:placeholder="placeholder"
@on-click="handleClick"></i-input>
</div>
</template>
<script>
import iInput from '../input/input.vue';
export default {
2017-03-07 15:06:38 +08:00
name: 'Search',
components: { iInput },
props: {
prefixCls: String,
placeholder: String,
query: String
},
2017-03-07 15:06:38 +08:00
data () {
return {
currentQuery: this.query
};
},
watch: {
query (val) {
this.currentQuery = val;
},
currentQuery (val) {
this.$emit('on-query-change', val);
}
},
computed: {
icon () {
2018-06-26 09:43:26 +08:00
return this.query === '' ? 'ios-search' : 'ios-close-circle';
}
},
methods: {
handleClick () {
2017-03-07 15:06:38 +08:00
if (this.currentQuery === '') return;
this.currentQuery = '';
this.$emit('on-query-clear');
2017-01-04 15:13:13 +08:00
}
}
2016-12-25 22:49:42 +08:00
};
</script>