vant components

This commit is contained in:
cookfront
2017-04-19 17:33:44 +08:00
commit 63c549d651
346 changed files with 25710 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
## 0.0.2 (2017-01-20)
* 改了bug A
* 加了功能B
## 0.0.1 (2017-01-10)
* 第一版
+26
View File
@@ -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)
+3
View File
@@ -0,0 +1,3 @@
import Radio from './src/radio';
export default Radio;
+10
View File
@@ -0,0 +1,10 @@
{
"name": "@youzan/van-radio",
"version": "0.0.1",
"description": "radio component",
"main": "./index.js",
"author": "zhangmin <zhangmin@youzan.com>",
"license": "MIT",
"devDependencies": {},
"dependencies": {}
}
+22
View File
@@ -0,0 +1,22 @@
<template>
<div class="van-radio-group">
<slot></slot>
</div>
</template>
<script>
export default {
name: 'van-radio-group',
props: {
value: {},
disabled: Boolean
},
watch: {
value(value) {
this.$emit('change', value);
}
}
};
</script>
+80
View File
@@ -0,0 +1,80 @@
<template>
<div
@click="handleRadioClick"
class="van-radio"
:class="{
'van-radio--disabled': isDisabled
}">
<span class="van-radio__input">
<input
:value="name"
v-model="currentValue"
type="radio"
class="van-radio__control"
:disabled="isDisabled">
<span class="van-icon" :class="{
'van-icon-checked': currentValue === name,
'van-icon-check': currentValue !== name
}">
</span>
</span>
<span class="van-radio__label" @click="handleLabelClick">
<slot></slot>
</span>
</div>
</template>
<script>
import findParent from 'src/mixins/findParent';
export default {
name: 'van-radio',
mixins: [findParent],
props: {
disabled: Boolean,
value: {},
name: [String, Number]
},
computed: {
isGroup() {
return !!this.findParentByComponentName('van-radio-group');
},
currentValue: {
get() {
return this.isGroup && this.parentGroup ? this.parentGroup.value : this.value;
},
set(val) {
if (this.isGroup && this.parentGroup) {
this.parentGroup.$emit('input', val);
} else {
this.$emit('input', val);
}
}
},
isDisabled() {
return this.isGroup && this.parentGroup
? this.parentGroup.disabled || this.disabled
: this.disabled;
}
},
methods: {
handleLabelClick() {
if (this.isDisabled) {
return;
}
this.currentValue = this.name;
},
handleRadioClick() {
this.$emit('click');
}
}
};
</script>