Commit 3f64571f authored by 杨奕's avatar 杨奕 Committed by baiyaaaaa

Carousel: responsive to item change (#2775)

parent 450cf81d
...@@ -528,6 +528,8 @@ export default { ...@@ -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 { ...@@ -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 { ...@@ -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
......
...@@ -96,6 +96,10 @@ export default { ...@@ -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 { ...@@ -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');
......
...@@ -110,7 +110,7 @@ describe('Carousel', () => { ...@@ -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', () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment