This commit is contained in:
zhuxiang 2017-03-01 14:51:27 +08:00
parent 0abb184056
commit 6808b06372
4 changed files with 52 additions and 7 deletions

View File

@ -15,13 +15,13 @@
### z-badge-group API ### z-badge-group API
| 参数 | 说明 | 类型 | 默认值 | 必须 | | 参数 | 说明 | 类型 | 默认值 | 必须 |
|-----------|-----------|-----------|-------------|-------------| |-----------|-----------|-----------|-------------|-------------|
| active-key | 激活的badge的索引 | string | '0'但必须子badge里的mark是有0位索引 | | | active-key | 激活的badge的索引 | string | '0'但必须子badge里的mark是有0位索引 | |
### z-badge API ### z-badge API
| 参数 | 说明 | 类型 | 默认值 | 可选值 | | 参数 | 说明 | 类型 | 默认值 | 必须 |
|-----------|-----------|-----------|-------------|-------------| |-----------|-----------|-----------|-------------|-------------|
| mark | badge的唯一key值 | string | '' | required | | mark | badge的唯一key值 | string | '' | required |
| title | badge的文案标题 | string | '' | required | | title | badge的文案标题 | string | '' | required |

View File

@ -1,3 +1,12 @@
<script>
export default {
methods: {
goSearch(value) {
alert(value)
}
}
};
</script>
## Search 组件 ## Search 组件
### 基础用法 ### 基础用法
@ -6,7 +15,25 @@
```html ```html
<z-search <z-search
placeholder="商品名称" placeholder="商品名称"
:on-search="goSearch"
> >
</z-search> </z-search>
``` ```
```javascript
export default {
methods: {
goSearch(value) {
alert(value)
}
}
};
```
::: :::
### API
| 参数 | 说明 | 类型 | 默认值 | 必须 |
|-----------|-----------|-----------|-------------|-------------|
| placeholder | input的placeholder文案 | string | | required |
| on-search | 点击回车后出发搜索回调 | function | function() {} | |

View File

@ -17,8 +17,12 @@ export default {
type: String, type: String,
required: true required: true
}, },
url: String, url: {
info: String type: String
},
info: {
type: String
}
}, },
methods: { methods: {
handleClick() { handleClick() {

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="z-search" :class="{ 'is-focus' : isFocus }"> <div class="z-search" :class="{ 'is-focus' : isFocus }">
<div class="z-search__input-wrap"> <div class="z-search__input-wrap">
<input type="text" :placeholder="placeholder" v-model="value" v-refocus="focusStatus" @focus="handleFocus"> <input type="text" :placeholder="placeholder" v-model="value" v-refocus="focusStatus" @focus="handleFocus" @keyup.enter="handleSearch">
<span class="zui-icon zui-icon-close" @click="handleClean"></span> <span class="zui-icon zui-icon-close" @click="handleClean"></span>
</div> </div>
<div class="z-search__cancel" :class="{ 'is-focus' : isFocus }" @click="handleBack">取消</div> <div class="z-search__cancel" :class="{ 'is-focus' : isFocus }" @click="handleBack">取消</div>
@ -12,7 +12,14 @@
export default { export default {
name: 'z-search', name: 'z-search',
props: { props: {
placeholder: String placeholder: {
type: String,
required: true
},
onSearch: {
type: Function,
default: function() {}
}
}, },
data() { data() {
return { return {
@ -30,16 +37,23 @@
}, },
methods: { methods: {
handleFocus() { handleFocus() {
// inputclose
this.isFocus = true; this.isFocus = true;
}, },
handleClean() { handleClean() {
// closevlaueinput
this.value = ''; this.value = '';
this.focusStatus = true; this.focusStatus = true;
}, },
handleBack() { handleBack() {
//
this.value = ''; this.value = '';
this.focusStatus = false; this.focusStatus = false;
this.isFocus = false; this.isFocus = false;
},
handleSearch(ev) {
// input
this.onSearch(ev.target.value)
} }
} }
}; };