support Transfer

support Transfer
This commit is contained in:
梁灏 2017-03-07 15:06:38 +08:00
parent 191068ac0c
commit 5b19b5f55f
8 changed files with 198 additions and 55 deletions

View file

@ -1,7 +1,7 @@
<template>
<div :class="prefixCls">
<i-input
:value.sync="query"
v-model="currentQuery"
size="small"
:icon="icon"
:placeholder="placeholder"
@ -12,12 +12,26 @@
import iInput from '../input/input.vue';
export default {
name: 'Search',
components: { iInput },
props: {
prefixCls: String,
placeholder: String,
query: String
},
data () {
return {
currentQuery: this.query
};
},
watch: {
query (val) {
this.currentQuery = val;
},
currentQuery (val) {
this.$emit('on-query-change', val);
}
},
computed: {
icon () {
return this.query === '' ? 'ios-search' : 'ios-close';
@ -25,17 +39,19 @@
},
methods: {
handleClick () {
if (this.query === '') return;
this.query = '';
}
},
events: {
'on-form-blur' () {
return false;
},
'on-form-change' () {
return false;
if (this.currentQuery === '') return;
this.currentQuery = '';
this.$emit('on-query-clear');
}
}
// todo
// events: {
// 'on-form-blur' () {
// return false;
// },
// 'on-form-change' () {
// return false;
// }
// }
};
</script>