vant components
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
## 0.0.2 (2017-01-20)
|
||||
|
||||
* 改了bug A
|
||||
* 加了功能B
|
||||
|
||||
## 0.0.1 (2017-01-10)
|
||||
|
||||
* 第一版
|
||||
@@ -0,0 +1,26 @@
|
||||
# @youzan/<%= name %>
|
||||
|
||||
!!! 请在此处填写你的文档最简单描述 !!!
|
||||
|
||||
[![version][version-image]][download-url]
|
||||
[![download][download-image]][download-url]
|
||||
|
||||
[version-image]: http://npm.qima-inc.com/badge/v/@youzan/<%= name %>.svg?style=flat-square
|
||||
[download-image]: http://npm.qima-inc.com/badge/d/@youzan/<%= name %>.svg?style=flat-square
|
||||
[download-url]: http://npm.qima-inc.com/package/@youzan/<%= name %>
|
||||
|
||||
## Demo
|
||||
|
||||
## Usage
|
||||
|
||||
## API
|
||||
|
||||
| 参数 | 说明 | 类型 | 默认值 | 可选值 |
|
||||
|-----------|-----------|-----------|-------------|-------------|
|
||||
| className | 自定义额外类名 | string | '' | '' |
|
||||
|
||||
|
||||
|
||||
|
||||
## License
|
||||
[MIT](https://opensource.org/licenses/MIT)
|
||||
@@ -0,0 +1,3 @@
|
||||
import Search from './src/search';
|
||||
|
||||
export default Search;
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "<%= name %>",
|
||||
"version": "<%= version %>",
|
||||
"description": "<%= description %>",
|
||||
"main": "./lib/index.js",
|
||||
"author": "<%= author %>",
|
||||
"license": "<%= license %>",
|
||||
"devDependencies": {},
|
||||
"dependencies": {}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
<template>
|
||||
<div class="van-search" :class="{ 'van-search--focus' : isFocus }">
|
||||
<div class="van-search__input-wrap">
|
||||
<van-icon name="search"></van-icon>
|
||||
<input
|
||||
type="text"
|
||||
:placeholder="placeholder"
|
||||
class="van-search__input"
|
||||
v-model="value"
|
||||
v-refocus="focusStatus"
|
||||
@focus="handleFocus"
|
||||
@keyup.enter="handleSearch">
|
||||
<van-icon name="clear" @click="handleClean" v-show="isFocus"></van-icon>
|
||||
</div>
|
||||
<div class="van-search__cancel" v-show="isFocus" @click="handleBack">取消</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ZanIcon from 'packages/icon';
|
||||
|
||||
export default {
|
||||
name: 'van-search',
|
||||
|
||||
components: {
|
||||
ZanIcon
|
||||
},
|
||||
|
||||
props: {
|
||||
placeholder: String
|
||||
},
|
||||
|
||||
watch: {
|
||||
value(val) {
|
||||
this.$emit('change', val);
|
||||
}
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
value: '',
|
||||
focusStatus: false,
|
||||
isFocus: false
|
||||
};
|
||||
},
|
||||
|
||||
directives: {
|
||||
refocus: {
|
||||
update: function(el, state) {
|
||||
if (state.value) {
|
||||
el.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
/**
|
||||
* 进入input焦点,出现close和取消
|
||||
*/
|
||||
handleFocus() {
|
||||
this.isFocus = true;
|
||||
},
|
||||
|
||||
/**
|
||||
* 点击close后清空vlaue后,再聚焦input框
|
||||
*/
|
||||
handleClean() {
|
||||
this.value = '';
|
||||
this.focusStatus = true;
|
||||
},
|
||||
|
||||
/**
|
||||
* 点击取消后,清空所有回复最初状态
|
||||
*/
|
||||
handleBack() {
|
||||
this.value = '';
|
||||
this.focusStatus = false;
|
||||
this.isFocus = false;
|
||||
this.$emit('cancel');
|
||||
},
|
||||
|
||||
/**
|
||||
* input输入回车后,发送回调
|
||||
*/
|
||||
handleSearch() {
|
||||
this.$emit('search', this.value);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
Reference in New Issue
Block a user