Merge branch 'next' of github.com:eleme/element-ui into next

# Conflicts:
#	bin/build-entry.js
#	src/index.js
pull/2/head
Leopoldthecoder 2016-08-15 16:13:59 +08:00
commit 609901ae7a
18 changed files with 186 additions and 183 deletions

View File

@ -1,7 +1,4 @@
{ {
"group": [
"./packages/group/index.js"
],
"select-dropdown": [ "select-dropdown": [
"./packages/select-dropdown/index.js" "./packages/select-dropdown/index.js"
], ],

View File

@ -41,22 +41,26 @@
### 多个勾选框,绑定到同一个数组 ### 多个勾选框,绑定到同一个数组
<div class="demo-box demo-checkbox"> <div class="demo-box demo-checkbox">
<el-checkbox class="checkbox" v-model="checkList" label="复选框 A"></el-checkbox> <el-checkbox-group v-model="checkList">
<el-checkbox class="checkbox" v-model="checkList" label="复选框 B"></el-checkbox> <el-checkbox class="checkbox" label="复选框 A"></el-checkbox>
<el-checkbox class="checkbox" v-model="checkList" label="复选框 C"></el-checkbox> <el-checkbox class="checkbox" label="复选框 B"></el-checkbox>
<el-checkbox class="checkbox" v-model="checkList" label="禁用" disabled></el-checkbox> <el-checkbox class="checkbox" label="复选框 C"></el-checkbox>
<el-checkbox class="checkbox" v-model="checkList" label="选中且禁用" disabled></el-checkbox> <el-checkbox class="checkbox" label="禁用" disabled></el-checkbox>
<el-checkbox class="checkbox" label="选中且禁用" disabled></el-checkbox>
</el-checkbox-group>
</div> </div>
<p>{{ checkList }}</p> <p>{{ checkList }}</p>
```html ```html
<template> <template>
<el-checkbox class="checkbox" v-model="checkList" label="复选框 A"></el-checkbox> <el-checkbox-group v-model="checkList">
<el-checkbox class="checkbox" v-model="checkList" label="复选框 B"></el-checkbox> <el-checkbox class="checkbox" label="复选框 A"></el-checkbox>
<el-checkbox class="checkbox" v-model="checkList" label="复选框 C"></el-checkbox> <el-checkbox class="checkbox" label="复选框 B"></el-checkbox>
<el-checkbox class="checkbox" v-model="checkList" label="禁用" disabled></el-checkbox> <el-checkbox class="checkbox" label="复选框 C"></el-checkbox>
<el-checkbox class="checkbox" v-model="checkList" label="选中且禁用" disabled></el-checkbox> <el-checkbox class="checkbox" label="禁用" disabled></el-checkbox>
<el-checkbox class="checkbox" label="选中且禁用" disabled></el-checkbox>
</el-checkbox-group>
</template> </template>
<script> <script>
@ -101,10 +105,21 @@ vm.name === vm.a
vm.name === vm.b vm.name === vm.b
``` ```
## API ## checkbox API
| 参数 | 说明 | 类型 | 可选值 | 默认值 | | 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------- |---------- |------------- |-------- | |---------- |-------- |---------- |------------- |-------- |
| model | 绑定值 | string\|string[]\|boolean | | | | value | 绑定值 | string\|string[]\|boolean | | |
| value | 真实值 | string | | | | label | 真实值 | string | | |
| label | 显示值,不填则显示 value | string | | | | true-label | 选中时的真实值 | string | | |
| true-label | 没有选中时的真实值 | string | | |
| disabled | 禁用 | boolean | true, false | false | | disabled | 禁用 | boolean | true, false | false |
## checkbox group API
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------- |---------- |------------- |-------- |
| value | 绑定值 | string\|string[]\|boolean | | |
## checkbox group 事件
| 事件名称 | 说明 | 回调参数 |
|---------- |-------- |---------- |
| change | 当绑定值变化时触发的事件 | (value: string) |

View File

@ -50,8 +50,8 @@
<el-pagination <el-pagination
@size-change="handleSizeChange" @sizechange="handleSizeChange"
@current-change="handleCurrentChange" @currentchange="handleCurrentChange"
layout="sizes, prev, pager, next, jumper, total" layout="sizes, prev, pager, next, jumper, total"
:total="1000"> :total="1000">
</el-pagination> </el-pagination>
@ -85,6 +85,10 @@
| current-page | 当前页数 | Number | | 0| | current-page | 当前页数 | Number | | 0|
| layout | 组件布局,子组件名用逗号分隔。| String | `prev`, `pager`, `next`, `jumper`, `slot`, `->`, `total` | 'prev, pager, next, jumper, slot, ->, total' | | layout | 组件布局,子组件名用逗号分隔。| String | `prev`, `pager`, `next`, `jumper`, `slot`, `->`, `total` | 'prev, pager, next, jumper, slot, ->, total' |
| page-sizes | 切换每页显示个数的子组件值 | Number[] | | [10, 20, 30, 40, 50, 100] | | page-sizes | 切换每页显示个数的子组件值 | Number[] | | [10, 20, 30, 40, 50, 100] |
| size-change | pageSize 改变时会触发的事件 | Function | | |
| current-change | currentPage 改变时会触发的事件 | Function | | | ## 事件
| 事件名称 | 说明 | 回调函数 |
|---------|--------|---------|
| sizechange | pageSize 改变时会触发 | `size` |
| currentchange | currentPage 改变时会触发 | `currentPage` |

View File

@ -16,16 +16,16 @@
## 基本用法 ## 基本用法
<div class="demo-box demo-radio"> <div class="demo-box demo-radio">
<el-radio class="radio" :value.sync="radio" label="单选框 A"></el-radio> <el-radio class="radio" v-model="radio" label="单选框 A"></el-radio>
<el-radio class="radio" :value.sync="radio" label="单选框 B"></el-radio> <el-radio class="radio" v-model="radio" label="单选框 B"></el-radio>
<el-radio class="radio" :value.sync="radio" label="单选框 C"></el-radio> <el-radio class="radio" v-model="radio" label="单选框 C"></el-radio>
</div> </div>
```html ```html
<template> <template>
<el-radio class="radio" :value.sync="radio" label="单选框 A"></el-radio> <el-radio class="radio" v-model="radio" label="单选框 A"></el-radio>
<el-radio class="radio" :value.sync="radio" label="单选框 B"></el-radio> <el-radio class="radio" v-model="radio" label="单选框 B"></el-radio>
<el-radio class="radio" :value.sync="radio" label="单选框 C"></el-radio> <el-radio class="radio" v-model="radio" label="单选框 C"></el-radio>
</template> </template>
<script> <script>
@ -42,7 +42,7 @@
## Radio Group ## Radio Group
<div class="demo-box demo-radio"> <div class="demo-box demo-radio">
<el-radio-group :value.sync="radio2"> <el-radio-group v-model="radio2">
<el-radio :label="9"></el-radio> <el-radio :label="9"></el-radio>
<el-radio :label="6"></el-radio> <el-radio :label="6"></el-radio>
<el-radio :label="3"></el-radio> <el-radio :label="3"></el-radio>
@ -50,7 +50,7 @@
</div> </div>
```html ```html
<el-radio-group :value.sync="radio2"> <el-radio-group v-model="radio2">
<el-radio :label="9"></el-radio> <el-radio :label="9"></el-radio>
<el-radio :label="6"></el-radio> <el-radio :label="6"></el-radio>
<el-radio :label="3"></el-radio> <el-radio :label="3"></el-radio>
@ -60,7 +60,7 @@
## Radio Group Button ## Radio Group Button
<div class="demo"> <div class="demo">
<el-radio-group :value.sync="radio31" size="large"> <el-radio-group v-model="radio31" size="large">
<el-radio-button label="上海"></el-radio-button> <el-radio-button label="上海"></el-radio-button>
<el-radio-button label="北京"></el-radio-button> <el-radio-button label="北京"></el-radio-button>
<el-radio-button label="广州" :disabled="true"></el-radio-button> <el-radio-button label="广州" :disabled="true"></el-radio-button>
@ -68,7 +68,7 @@
</el-radio-group> </el-radio-group>
</div> </div>
<div class="demo"> <div class="demo">
<el-radio-group :value.sync="radio32"> <el-radio-group v-model="radio32">
<el-radio-button label="上海"></el-radio-button> <el-radio-button label="上海"></el-radio-button>
<el-radio-button label="北京"></el-radio-button> <el-radio-button label="北京"></el-radio-button>
<el-radio-button label="广州" :disabled="true"></el-radio-button> <el-radio-button label="广州" :disabled="true"></el-radio-button>
@ -76,7 +76,7 @@
</el-radio-group> </el-radio-group>
</div> </div>
<div class="demo"> <div class="demo">
<el-radio-group :value.sync="radio33" size="small"> <el-radio-group v-model="radio33" size="small">
<el-radio-button label="上海"></el-radio-button> <el-radio-button label="上海"></el-radio-button>
<el-radio-button label="北京"></el-radio-button> <el-radio-button label="北京"></el-radio-button>
<el-radio-button label="广州" :disabled="true"></el-radio-button> <el-radio-button label="广州" :disabled="true"></el-radio-button>
@ -85,19 +85,19 @@
</div> </div>
```html ```html
<el-radio-group :value.sync="radio31" size="large"> <el-radio-group v-model="radio31" size="large">
<el-radio-button label="上海"></el-radio-button> <el-radio-button label="上海"></el-radio-button>
<el-radio-button label="北京"></el-radio-button> <el-radio-button label="北京"></el-radio-button>
<el-radio-button label="广州" :disabled="true"></el-radio-button> <el-radio-button label="广州" :disabled="true"></el-radio-button>
<el-radio-button label="深圳"></el-radio-button> <el-radio-button label="深圳"></el-radio-button>
</el-radio-group> </el-radio-group>
<el-radio-group :value.sync="radio32"> <el-radio-group v-model="radio32">
<el-radio-button label="上海"></el-radio-button> <el-radio-button label="上海"></el-radio-button>
<el-radio-button label="北京"></el-radio-button> <el-radio-button label="北京"></el-radio-button>
<el-radio-button label="广州" :disabled="true"></el-radio-button> <el-radio-button label="广州" :disabled="true"></el-radio-button>
<el-radio-button label="深圳"></el-radio-button> <el-radio-button label="深圳"></el-radio-button>
</el-radio-group> </el-radio-group>
<el-radio-group :value.sync="radio33" size="small"> <el-radio-group v-model="radio33" size="small">
<el-radio-button label="上海"></el-radio-button> <el-radio-button label="上海"></el-radio-button>
<el-radio-button label="北京"></el-radio-button> <el-radio-button label="北京"></el-radio-button>
<el-radio-button label="广州" :disabled="true"></el-radio-button> <el-radio-button label="广州" :disabled="true"></el-radio-button>
@ -108,31 +108,32 @@
## 禁用 ## 禁用
<div class="demo-box demo-radio"> <div class="demo-box demo-radio">
<el-radio disabled :value.sync="radio" label="禁用"></el-radio> <el-radio disabled v-model="radio" label="禁用"></el-radio>
<el-radio disabled :value.sync="radio1" label="选中且禁用"></el-radio> <el-radio disabled v-model="radio1" label="选中且禁用"></el-radio>
</div> </div>
```html ```html
<el-radio disabled :value.sync="radio" label="禁用"></el-radio> <el-radio disabled v-model="radio" label="禁用"></el-radio>
<el-radio disabled :value.sync="radio1" label="选中且禁用"></el-radio> <el-radio disabled v-model="radio1" label="选中且禁用"></el-radio>
``` ```
## Radio API ## Radio API
| 参数 | 说明 | 类型 | 可选值 | 默认值 | | 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------- |---------- |------------- |-------- | |---------- |-------- |---------- |------------- |-------- |
| value | 绑定值 | string | | | | value | 绑定值 | string,number | | |
| label | 真实值 | string | | | | label | 真实值 | string,number | | |
| disabled | 禁用 | boolean | true, false | false | | disabled | 禁用 | boolean | true, false | false |
## Radio Group API ## Radio Group API
| 参数 | 说明 | 类型 | 可选值 | 默认值 | | 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------- |---------- |------------- |-------- | |---------- |-------- |---------- |------------- |-------- |
| value | 绑定值 | string | | | | value | 绑定值 | string,number | | |
| size | 尺寸 | string | large, small | | | size | 尺寸 | string | large, small | |
| change | 绑定值变化时触发的事件 | Function(value) | | |
## Radio Button API ## Radio Button API
| 参数 | 说明 | 类型 | 可选值 | 默认值 | | 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------- |---------- |------------- |-------- | |---------- |-------- |---------- |------------- |-------- |
| label | 真实值 | string | | | | label | 真实值 | string,number | | |
| disabled | 禁用 | boolean | true, false | false | | disabled | 禁用 | boolean | true, false | false |

View File

@ -779,7 +779,11 @@
| remote | 是否为远程搜索 | boolean | | false | | remote | 是否为远程搜索 | boolean | | false |
| remote-method | 远程搜索方法,当搜索关键字变化时会调用该方法,参数为目前的搜索关键字 | function | | | | remote-method | 远程搜索方法,当搜索关键字变化时会调用该方法,参数为目前的搜索关键字 | function | | |
| loading | 是否正在从远程获取数据 | boolean | | false | | loading | 是否正在从远程获取数据 | boolean | | false |
| change | value 发生变化时的回调函数,参数为 value 的值 | function | | |
### el-select 事件
| 事件名称 | 说明 | 回调参数 |
|---------|---------|---------|
| change | value 发生变化| `value` |
### el-option-group ### el-option-group
| 参数 | 说明 | 类型 | 可选值 | 默认值 | | 参数 | 说明 | 类型 | 可选值 | 默认值 |

View File

@ -15,8 +15,8 @@
title: '选项卡四', title: '选项卡四',
content: '选项卡四内容' content: '选项卡四内容'
}], }],
activeKey: '3', activeName: '3',
activeKey2: '' activeName2: ''
} }
} }
} }
@ -30,7 +30,7 @@
## 基础使用 ## 基础使用
<div> <div>
<el-tabs :active-key="activeKey"> <el-tabs :active-name="activeName">
<el-tab-pane label="选项卡一">选项卡一内容</el-tab-pane> <el-tab-pane label="选项卡一">选项卡一内容</el-tab-pane>
<el-tab-pane label="选项卡二">选项卡二内容</el-tab-pane> <el-tab-pane label="选项卡二">选项卡二内容</el-tab-pane>
<el-tab-pane label="选项卡三">选项卡三内容</el-tab-pane> <el-tab-pane label="选项卡三">选项卡三内容</el-tab-pane>
@ -39,7 +39,7 @@
</div> </div>
```html ```html
<el-tabs :active-key="activeKey"> <el-tabs :active-name="activeName">
<el-tab-pane label="选项卡一">选项卡一内容</el-tab-pane> <el-tab-pane label="选项卡一">选项卡一内容</el-tab-pane>
<el-tab-pane label="选项卡二">选项卡二内容</el-tab-pane> <el-tab-pane label="选项卡二">选项卡二内容</el-tab-pane>
<el-tab-pane label="选项卡三">选项卡三内容</el-tab-pane> <el-tab-pane label="选项卡三">选项卡三内容</el-tab-pane>
@ -77,7 +77,7 @@
<el-tab-pane label="选项卡四">选项卡四内容</el-tab-pane> <el-tab-pane label="选项卡四">选项卡四内容</el-tab-pane>
</el-tabs> </el-tabs>
</div> </div>
{{activeKey2}} {{activeName2}}
```html ```html
<el-tabs type="card" :closable="true"> <el-tabs type="card" :closable="true">
@ -113,8 +113,8 @@
|---------- |-------- |---------- |------------- |-------- | |---------- |-------- |---------- |------------- |-------- |
| type | 风格类型 | string | card, border-card | | | type | 风格类型 | string | card, border-card | |
| closable | 真实值 | boolean | true, false | false | | closable | 真实值 | boolean | true, false | false |
| defaultActiveKey | 如果没有设置 activeKey, 则使用该值 | string | | 第一个面板 | | defaultActiveName | 如果没有设置 activeName, 则使用该值 | string | | 第一个面板 |
| activeKey | 当前选中面板的key | string | | | | activeName | 当前选中面板的 name | string | | |
| tab.click | tab 被点击的回调 | string | | | | tab.click | tab 被点击的回调 | string | | |
| tab.remove | tab 被删除的回调 | string | | | | tab.remove | tab 被删除的回调 | string | | |
@ -122,4 +122,4 @@
| 参数 | 说明 | 类型 | 可选值 | 默认值 | | 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------- |---------- |------------- |-------- | |---------- |-------- |---------- |------------- |-------- |
| label | 选项卡标题 | string | | | | label | 选项卡标题 | string | | |
| key | 与选项卡activeKey对应的标识符 | string | | 该选项卡在选项卡中的index值,如第一个选项卡则为'1' | | name | 与选项卡 activeName 对应的标识符 | string | | 该选项卡在选项卡中的 name 值,如第一个选项卡则为'1' |

View File

@ -15,6 +15,7 @@
watch: { watch: {
value(value) { value(value) {
this.$emit('change', value);
this.dispatch('form-item', 'el.form.change', value); this.dispatch('form-item', 'el.form.change', value);
} }
} }

View File

@ -3,7 +3,7 @@
<span class="el-checkbox__input"> <span class="el-checkbox__input">
<span class="el-checkbox__inner" <span class="el-checkbox__inner"
:class="{ :class="{
'is-disabled': isLimit || disabled, 'is-disabled': disabled,
'is-checked': checked, 'is-checked': checked,
'is-indeterminate': indeterminate, 'is-indeterminate': indeterminate,
'is-focus': focus 'is-focus': focus
@ -18,7 +18,7 @@
type="checkbox" type="checkbox"
@focus="focus = true" @focus="focus = true"
@blur="focus = false" @blur="focus = false"
:disabled="isLimit || disabled" :disabled="disabled"
ref="checkbox"> ref="checkbox">
<input <input
v-else v-else
@ -28,7 +28,7 @@
@focus="focus = true" @focus="focus = true"
@blur="focus = false" @blur="focus = false"
type="checkbox" type="checkbox"
:disabled="isLimit || disabled"> :disabled="disabled">
</span> </span>
<span class="el-checkbox__label"> <span class="el-checkbox__label">
<slot></slot> <slot></slot>
@ -38,20 +38,7 @@
</template> </template>
<script> <script>
import Emitter from 'main/mixins/emitter'; import Emitter from 'main/mixins/emitter';
/**
* checkbox
* @module components/basic/checkbox
* @desc 多选按钮
* @param {string[]} value - 绑定值
* @param {string} value - 真实值
* @param {string} [label] - 显示值
* @param {boolean} [disabled=false] - 是否禁用
*
* @example
* <el-checkbox :value.sync="data" value="Jack"></el-checkbox>
* <el-checkbox :value.sync="data" value="John"></el-checkbox>
* <el-checkbox :value.sync="data" value="Mike" disabled></el-checkbox>
*/
export default { export default {
name: 'ElCheckbox', name: 'ElCheckbox',
@ -64,12 +51,8 @@
}, },
indeterminate: Boolean, indeterminate: Boolean,
disabled: Boolean, disabled: Boolean,
trueLabel: { trueLabel: [String, Number],
default: '' falseLabel: [String, Number]
},
falseLabel: {
default: ''
}
}, },
computed: { computed: {
@ -92,7 +75,7 @@
return this._value; return this._value;
} else if (type === '[object Array]') { } else if (type === '[object Array]') {
return this._value.indexOf(this.label) > -1; return this._value.indexOf(this.label) > -1;
} else if (type === '[object String]') { } else if (type === '[object String]' || type === '[object Number]') {
return this._value === this.trueLabel; return this._value === this.trueLabel;
} }
} }
@ -100,26 +83,14 @@
data() { data() {
return { return {
isLimit: false,
focus: false focus: false
}; };
}, },
watch: { watch: {
checked(sure) { checked(sure) {
this.$emit('on-change', sure); this.$emit('change', sure);
this.dispatch('element.checkbox', sure);
} }
},
created() {
this.$on('element.checkbox.disabled', () => {
if (this.checked) return;
this.isLimit = true;
});
this.$on('element.checkbox.enabled', () => {
this.isLimit = false;
});
} }
}; };
</script> </script>

View File

@ -71,7 +71,7 @@
} }
if (newPage !== currentPage) { if (newPage !== currentPage) {
this.$emit('currentChange', newPage); this.$emit('currentchange', newPage);
} }
} }
}, },

View File

@ -49,7 +49,7 @@ export default {
const TEMPLATE_MAP = { const TEMPLATE_MAP = {
prev: <prev></prev>, prev: <prev></prev>,
jumper: <jumper></jumper>, jumper: <jumper></jumper>,
pager: <pager currentPage={ this.internalCurrentPage } pageCount={ this.pageCount } on-currentChange={ this.handleCurrentChange }></pager>, pager: <pager currentPage={ this.internalCurrentPage } pageCount={ this.pageCount } on-currentchange={ this.handleCurrentChange }></pager>,
next: <next></next>, next: <next></next>,
sizes: <sizes></sizes>, sizes: <sizes></sizes>,
slot: <slot></slot>, slot: <slot></slot>,
@ -114,6 +114,12 @@ export default {
}, },
Sizes: { Sizes: {
created() {
if (Array.isArray(this.$parent.pageSizes)) {
this.$parent.internalPageSize = this.$parent.pageSizes[0];
}
},
render(h) { render(h) {
return ( return (
<span class="el-pagination__sizes"> <span class="el-pagination__sizes">
@ -144,7 +150,7 @@ export default {
handleChange(val) { handleChange(val) {
if (val !== this.$parent.internalPageSize) { if (val !== this.$parent.internalPageSize) {
this.$parent.internalPageSize = val = parseInt(val, 10); this.$parent.internalPageSize = val = parseInt(val, 10);
this.$parent.$emit('size-change', val); this.$parent.$emit('sizechange', val);
} }
} }
} }
@ -167,7 +173,7 @@ export default {
this.$parent.internalCurrentPage = this.$parent.getValidCurrentPage(target.value); this.$parent.internalCurrentPage = this.$parent.getValidCurrentPage(target.value);
if (target.value !== this.oldValue && Number(target.value) === this.$parent.internalCurrentPage) { if (target.value !== this.oldValue && Number(target.value) === this.$parent.internalCurrentPage) {
this.$parent.$emit('current-change', this.$parent.internalCurrentPage); this.$parent.$emit('currentchange', this.$parent.internalCurrentPage);
} }
this.oldValue = null; this.oldValue = null;
@ -209,7 +215,7 @@ export default {
methods: { methods: {
handleCurrentChange(val) { handleCurrentChange(val) {
this.internalCurrentPage = this.getValidCurrentPage(val); this.internalCurrentPage = this.getValidCurrentPage(val);
this.$emit('current-change', this.internalCurrentPage); this.$emit('currentchange', this.internalCurrentPage);
}, },
prev() { prev() {
@ -218,7 +224,7 @@ export default {
this.internalCurrentPage = this.getValidCurrentPage(newVal); this.internalCurrentPage = this.getValidCurrentPage(newVal);
if (this.internalCurrentPage !== oldPage) { if (this.internalCurrentPage !== oldPage) {
this.$emit('current-change', this.internalCurrentPage); this.$emit('currentchange', this.internalCurrentPage);
} }
}, },
@ -228,7 +234,7 @@ export default {
this.internalCurrentPage = this.getValidCurrentPage(newVal); this.internalCurrentPage = this.getValidCurrentPage(newVal);
if (this.internalCurrentPage !== oldPage) { if (this.internalCurrentPage !== oldPage) {
this.$emit('current-change', this.internalCurrentPage); this.$emit('currentchange', this.internalCurrentPage);
} }
}, },
@ -238,7 +244,7 @@ export default {
this.internalCurrentPage = this.getValidCurrentPage(newVal); this.internalCurrentPage = this.getValidCurrentPage(newVal);
if (this.internalCurrentPage !== oldPage) { if (this.internalCurrentPage !== oldPage) {
this.$emit('current-change', this.internalCurrentPage); this.$emit('currentchange', this.internalCurrentPage);
} }
}, },
@ -248,7 +254,7 @@ export default {
this.internalCurrentPage = this.getValidCurrentPage(newVal); this.internalCurrentPage = this.getValidCurrentPage(newVal);
if (this.internalCurrentPage !== oldPage) { if (this.internalCurrentPage !== oldPage) {
this.$emit('current-change', this.internalCurrentPage); this.$emit('currentchange', this.internalCurrentPage);
} }
}, },

View File

@ -17,7 +17,7 @@
return this.$parent.value; return this.$parent.value;
}, },
set(newValue) { set(newValue) {
this.$parent.value = newValue; this.$parent.$emit('input', newValue);
} }
} }
}, },
@ -44,7 +44,7 @@
:disabled="disabled"> :disabled="disabled">
<span class="el-radio-button__inner"> <span class="el-radio-button__inner">
<slot></slot> <slot></slot>
<template v-if="!_slotContents">{{label}}</template> <template v-if="!$slots.default">{{label}}</template>
</span> </span>
</label> </label>
</template> </template>

View File

@ -4,18 +4,17 @@
export default { export default {
name: 'ElRadioGroup', name: 'ElRadioGroup',
componentName: 'radio-group',
mixins: [emitter], mixins: [emitter],
props: { props: {
value: { value: [String, Number],
default: '',
twoWay: true,
required: true
},
size: String size: String
}, },
watch: { watch: {
value(value) { value(value) {
this.$emit('change', value);
this.dispatch('form-item', 'el.form.change', [this.value]); this.dispatch('form-item', 'el.form.change', [this.value]);
} }
} }

View File

@ -19,7 +19,7 @@
</span> </span>
<span class="el-radio__label"> <span class="el-radio__label">
<slot></slot> <slot></slot>
<template v-if="!_slotContents">{{label}}</template> <template v-if="!$slots.default">{{label}}</template>
</span> </span>
</label> </label>
</template> </template>
@ -28,9 +28,7 @@
name: 'ElRadio', name: 'ElRadio',
props: { props: {
value: { value: [String, Number],
twoWay: true
},
label: { label: {
type: [String, Number], type: [String, Number],
required: true required: true
@ -43,11 +41,6 @@
focus: false focus: false
}; };
}, },
watch: {
value(value) {
this.$emit('onchange', value);
}
},
computed: { computed: {
_value: { _value: {
get() { get() {
@ -55,9 +48,9 @@
}, },
set(newValue) { set(newValue) {
if (this.value !== undefined) { if (this.value !== undefined) {
this.value = newValue; this.$emit('input', newValue);
} else { } else {
this.$parent.value = newValue; this.$parent.$emit('input', newValue);
} }
} }
} }

View File

@ -7,9 +7,7 @@
type: String, type: String,
required: true required: true
}, },
key: { name: String
type: String
}
}, },
data() { data() {
@ -18,7 +16,8 @@
transition: '', transition: '',
paneStyle: { paneStyle: {
position: 'relative' position: 'relative'
} },
key: ''
}; };
}, },
@ -28,17 +27,20 @@
} }
}, },
events: {
},
computed: { computed: {
show() { show() {
return this.$parent.activeKey === this.key; return this.$parent.currentName === this.key;
} }
}, },
watch: { watch: {
'$parent.activeKey'(newValue, oldValue) { name: {
immediate: true,
handler(val) {
this.key = val;
}
},
'$parent.currentName'(newValue, oldValue) {
if (this.key === newValue) { if (this.key === newValue) {
this.transition = newValue > oldValue ? 'slideInRight' : 'slideInLeft'; this.transition = newValue > oldValue ? 'slideInRight' : 'slideInLeft';
} }

View File

@ -8,20 +8,23 @@
required: true required: true
}, },
closable: Boolean closable: Boolean
},
data() {
return {
showClose: false
};
} }
}; };
</script> </script>
<template> <template>
<div class="el-tabs__item" <div
class="el-tabs__item"
:class="{ :class="{
'is-active': $parent.activeKey === tab.key, 'is-active': $parent.currentName === tab.key,
'is-disabled': tab.disabled, 'is-disabled': tab.disabled,
'is-closable': closable 'is-closable': closable
}">{{tab.label}}<span class="el-icon-close" v-if="closable" @click="$emit('onremove', tab, $event)"></span></div> }">
{{tab.label}}
<span
class="el-icon-close"
v-if="closable"
@click="$emit('onremove', tab, $event)">
</span>
</div>
</template> </template>

View File

@ -11,12 +11,8 @@
props: { props: {
type: String, type: String,
tabPosition: String, tabPosition: String,
defaultActiveKey: { defaultActiveName: String,
type: String activeName: String,
},
activeKey: {
type: String
},
closable: false, closable: false,
tabWidth: 0 tabWidth: 0
}, },
@ -25,34 +21,22 @@
return { return {
tabs: [], tabs: [],
children: null, children: null,
activeTab: null activeTab: null,
currentName: 0,
barStyle: ''
}; };
}, },
computed: { watch: {
barStyle: { activeName: {
cache: false, immediate: true,
get() { handler(val) {
if (this.type) return {}; this.currentName = val || 0;
var style = {};
var offset = 0;
var tabWidth = 0;
this.tabs.every((tab, index) => {
let $el = this.$refs.tabs[index].$el;
if (tab.key !== this.activeKey) {
offset += $el.clientWidth;
return true;
} else {
tabWidth = $el.clientWidth;
return false;
} }
}); },
style.width = tabWidth + 'px'; 'currentName'() {
style.transform = `translateX(${offset}px)`; this.calcBarStyle();
return style;
}
} }
}, },
@ -67,27 +51,49 @@
this.tabs.splice(index, 1); this.tabs.splice(index, 1);
} }
if (tab.key === this.activeKey) { if (tab.key === this.currentName) {
let deleteIndex = this.$children.indexOf(tab); let deleteIndex = this.$children.indexOf(tab);
let nextChild = this.$children[deleteIndex + 1]; let nextChild = this.$children[deleteIndex + 1];
let prevChild = this.$children[deleteIndex - 1]; let prevChild = this.$children[deleteIndex - 1];
this.activeKey = nextChild ? nextChild.key : prevChild ? prevChild.key : '-1'; this.currentName = nextChild ? nextChild.key : prevChild ? prevChild.key : '-1';
} }
this.$emit('tab.remove', tab); this.$emit('tab.remove', tab);
}, },
handleTabClick(tab) { handleTabClick(tab) {
this.activeKey = tab.key; this.currentName = tab.key;
this.$emit('tab.click', tab); this.$emit('tab.click', tab);
},
calcBarStyle() {
if (this.type) return {};
var style = {};
var offset = 0;
var tabWidth = 0;
this.tabs.every((tab, index) => {
let $el = this.$refs.tabs[index].$el;
if (tab.key !== this.currentName) {
offset += $el.clientWidth;
return true;
} else {
tabWidth = $el.clientWidth;
return false;
}
});
style.width = tabWidth + 'px';
style.transform = `translateX(${offset}px)`;
this.barStyle = style;
} }
}, },
ready() {
if (!this.activeKey) { mounted() {
this.activeKey = this.defaultActiveKey || this.$children[0].key; if (!this.currentName) {
this.currentName = this.defaultActiveName || this.$children[0].key;
} }
this.$children.forEach(tab => { this.$children.forEach(tab => this.tabs.push(tab));
this.tabs.push(tab); this.$nextTick(() => this.calcBarStyle());
});
} }
}; };
</script> </script>
@ -97,13 +103,17 @@
<div class="el-tabs__header"> <div class="el-tabs__header">
<el-tab <el-tab
v-for="tab in tabs" v-for="tab in tabs"
v-ref:tabs ref="tabs"
:tab="tab" :tab="tab"
:closable="closable" :closable="closable"
@onremove="removeTab" @onremove="removeTab"
@click="handleTabClick(tab)" @click.native="handleTabClick(tab)">
></el-tab> </el-tab>
<div class="el-tabs__active-bar" v-bind:style="barStyle" v-if="!this.type && tabs.length > 0"></div> <div
class="el-tabs__active-bar"
:style="barStyle"
v-if="!this.type && tabs.length > 0">
</div>
</div> </div>
<div class="el-tabs__content"> <div class="el-tabs__content">

View File

@ -6,7 +6,7 @@
<span class="el-tree-node__expand-icon" <span class="el-tree-node__expand-icon"
:class="{ 'is-leaf': node.isLeaf, expanded: !node.isLeaf && expanded }" :class="{ 'is-leaf': node.isLeaf, expanded: !node.isLeaf && expanded }"
></span> ></span>
<el-checkbox v-if="showCheckbox" :indeterminate="node.indeterminate" v-model="node.checked" :true-label="true" :false-label="false" @on-change="handleCheckChange"></el-checkbox> <el-checkbox v-if="showCheckbox" :indeterminate="node.indeterminate" v-model="node.checked" :true-label="true" :false-label="false" @change="handleCheckChange"></el-checkbox>
<!--<span class="el-tree-node__icon {{ node.icon }} {{ node.loading ? 'el-icon-loading' : '' }}" v-if="node.icon"></span>--> <!--<span class="el-tree-node__icon {{ node.icon }} {{ node.loading ? 'el-icon-loading' : '' }}" v-if="node.icon"></span>-->
<span class="el-tree-node__label">{{ node.label }}</span> <span class="el-tree-node__label">{{ node.label }}</span>
</div> </div>

View File

@ -1,4 +1,3 @@
import Group from '../packages/group/index.js';
import SelectDropdown from '../packages/select-dropdown/index.js'; import SelectDropdown from '../packages/select-dropdown/index.js';
import Pagination from '../packages/pagination/index.js'; import Pagination from '../packages/pagination/index.js';
import Dialog from '../packages/dialog/index.js'; import Dialog from '../packages/dialog/index.js';
@ -53,7 +52,6 @@ import Message from '../packages/message/index.js';
const install = function(Vue) { const install = function(Vue) {
if (install.installed) return; if (install.installed) return;
Vue.component(Group.name, Group);
Vue.component(SelectDropdown.name, SelectDropdown); Vue.component(SelectDropdown.name, SelectDropdown);
Vue.component(Pagination.name, Pagination); Vue.component(Pagination.name, Pagination);
Vue.component(Dialog.name, Dialog); Vue.component(Dialog.name, Dialog);
@ -119,7 +117,6 @@ if (typeof window !== 'undefined' && window.Vue) {
module.exports = { module.exports = {
install, install,
Group,
SelectDropdown, SelectDropdown,
Pagination, Pagination,
Dialog, Dialog,