Carousel: responsive to item change (#2775)

pull/2898/head
杨奕 2017-02-18 15:11:41 +08:00 committed by baiyaaaaa
parent 450cf81ded
commit 3f64571fcc
3 changed files with 14 additions and 7 deletions

View File

@ -528,6 +528,8 @@ export default {
custom-item="my-item-zh" custom-item="my-item-zh"
placeholder="请输入内容" placeholder="请输入内容"
@select="handleSelect" @select="handleSelect"
icon="edit"
:on-icon-click="handleIconClick"
></el-autocomplete> ></el-autocomplete>
<style> <style>
@ -639,6 +641,9 @@ export default {
}, },
handleSelect(item) { handleSelect(item) {
console.log(item); console.log(item);
},
handleIconClick(ev) {
console.log(ev);
} }
}, },
mounted() { mounted() {
@ -792,7 +797,7 @@ export default {
| fetch-suggestions | 返回输入建议的方法,仅当你的输入建议数据 resolve 时,通过调用 callback(data:[]) 来返回它 | Function(queryString, callback) | — | — | | fetch-suggestions | 返回输入建议的方法,仅当你的输入建议数据 resolve 时,通过调用 callback(data:[]) 来返回它 | Function(queryString, callback) | — | — |
| popper-class | Autocomplete 下拉列表的类名 | string | — | — | | popper-class | Autocomplete 下拉列表的类名 | string | — | — |
| trigger-on-focus | 是否在输入框 focus 时显示建议列表 | boolean | — | true | | trigger-on-focus | 是否在输入框 focus 时显示建议列表 | boolean | — | true |
| on-icon-click | 点击 Input 内的图标的钩子函数 | function | — | — | | on-icon-click | 点击图标的回调函数 | function | — | — |
| icon | 输入框尾部图标 | string | — | — | | icon | 输入框尾部图标 | string | — | — |
### Autocomplete Events ### Autocomplete Events

View File

@ -96,6 +96,10 @@ export default {
}, },
watch: { watch: {
items() {
this.setActiveItem(0);
},
activeIndex(val, oldVal) { activeIndex(val, oldVal) {
this.resetItemPosition(); this.resetItemPosition();
this.$emit('change', val, oldVal); this.$emit('change', val, oldVal);
@ -139,11 +143,9 @@ export default {
}); });
}, },
handleItemChange() { handleItemChange: debounce(100, function() {
debounce(100, () => { this.updateItems();
this.updateItems(); }),
});
},
updateItems() { updateItems() {
this.items = this.$children.filter(child => child.$options.name === 'ElCarouselItem'); this.items = this.$children.filter(child => child.$options.name === 'ElCarouselItem');

View File

@ -110,7 +110,7 @@ describe('Carousel', () => {
expect(vm.val).to.equal(1); expect(vm.val).to.equal(1);
expect(vm.oldVal).to.equal(0); expect(vm.oldVal).to.equal(0);
done(); done();
}, 100); }, 60);
}); });
describe('manual control', () => { describe('manual control', () => {