search add change event

This commit is contained in:
cookfront 2017-03-30 14:47:52 +08:00
parent 2b3394bd35
commit 50d87fa634
2 changed files with 10 additions and 2 deletions

View File

@ -3,6 +3,9 @@ export default {
methods: {
goSearch(value) {
alert(value)
},
handleChange(value) {
console.log(value);
}
}
};
@ -14,7 +17,7 @@ export default {
:::demo 基础用法
```html
<zan-search placeholder="商品名称" @search="goSearch"></zan-search>
<zan-search placeholder="商品名称" @search="goSearch" @change="handleChange"></zan-search>
<script>
export default {
methods: {

View File

@ -2,7 +2,7 @@
<div class="zan-search" :class="{ 'zan-search--focus' : isFocus }">
<div class="zan-search__input-wrap">
<zan-icon name="search"></zan-icon>
<input type="text" :placeholder="placeholder" v-model="value" v-refocus="focusStatus" @focus="handleFocus" @keyup.enter="handleSearch">
<input type="text" :placeholder="placeholder" v-model="value" v-refocus="focusStatus" @focus="handleFocus" @keyup.enter="handleSearch">
<zan-icon name="clear" @click="handleClean"></zan-icon>
</div>
<div class="zan-search__cancel" :class="{ 'zan-search__cancel--focus' : isFocus }" @click="handleBack">取消</div>
@ -22,6 +22,11 @@
type: String
}
},
watch: {
value(val) {
this.$emit('change', val);
}
},
data() {
return {
value: '',