From b1c118d85e0d93e38d09863d8ee94b01c302102b Mon Sep 17 00:00:00 2001 From: 梁灏 Date: Fri, 3 Mar 2017 17:46:09 +0800 Subject: [PATCH] support Dropdown --- CHANGE.md | 7 ++++++- README.md | 4 ++-- src/components/dropdown/dropdown-item.vue | 7 ++++--- src/components/dropdown/dropdown.vue | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------- src/components/select/dropdown.vue | 6 +++--- src/components/slider/slider.vue | 1 + src/index.js | 8 ++++---- test/app.vue | 1 + test/main.js | 4 ++++ test/routers/dropdown.vue | 8 ++------ 10 files changed, 91 insertions(+), 48 deletions(-) diff --git a/CHANGE.md b/CHANGE.md index e44ee93..a6caf9f 100644 --- a/CHANGE.md +++ b/CHANGE.md @@ -28,4 +28,9 @@ class 改为了 className 改名为 iCircle ### Tabs 废弃 activeKey,改用 value,使用 v-model,key 更名为 name -### popper.js 将 prop: visible 移至 data 里 \ No newline at end of file +### popper.js 将 prop: visible 移至 data 里 +### Slider +支持 v-model +### Dropdown +DropdownItem key 改为 name, Dropdown 的 visible 要使用 @on-visible-change 捕获,不再 sync +DropdownItem 里,this.$parent.$parent 与1.0 有区别 \ No newline at end of file diff --git a/README.md b/README.md index 806bedd..6f88487 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ - [x] Switch - [ ] Table - [ ] Select -- [ ] Slider +- [x] Slider - [ ] DatePicker - [ ] TimePicker - [ ] Cascader @@ -51,7 +51,7 @@ - [x] Tree - [ ] Menu - [x] Tabs -- [ ] Dropdown +- [x] Dropdown - [ ] Page - [ ] Breadcrumb - [x] Steps diff --git a/src/components/dropdown/dropdown-item.vue b/src/components/dropdown/dropdown-item.vue index 64390dd..463dce1 100644 --- a/src/components/dropdown/dropdown-item.vue +++ b/src/components/dropdown/dropdown-item.vue @@ -5,8 +5,9 @@ const prefixCls = 'ivu-dropdown-item'; export default { + name: 'DropdownItem', props: { - key: { + name: { type: [String, Number] }, disabled: { @@ -36,7 +37,7 @@ }, methods: { handleClick () { - const $parent = this.$parent.$parent; + const $parent = this.$parent.$parent.$parent; const hasChildren = this.$parent && this.$parent.$options.name === 'Dropdown'; if (this.disabled) { @@ -50,7 +51,7 @@ $parent.$emit('on-hover-click'); } } - $parent.$emit('on-click', this.key); + $parent.$emit('on-click', this.name); } } }; diff --git a/src/components/dropdown/dropdown.vue b/src/components/dropdown/dropdown.vue index 98a739c..db972b4 100644 --- a/src/components/dropdown/dropdown.vue +++ b/src/components/dropdown/dropdown.vue @@ -4,8 +4,10 @@ v-clickoutside="handleClose" @mouseenter="handleMouseenter" @mouseleave="handleMouseleave"> -
- +
+ + + diff --git a/src/components/select/dropdown.vue b/src/components/select/dropdown.vue index 27e02b2..f4f32bd 100644 --- a/src/components/select/dropdown.vue +++ b/src/components/select/dropdown.vue @@ -15,7 +15,7 @@ data () { return { popper: null, - width: '', + width: '' }; }, computed: { @@ -33,7 +33,7 @@ }); } else { this.$nextTick(() => { - this.popper = new Popper(this.$parent.$els.reference, this.$el, { + this.popper = new Popper(this.$parent.$refs.reference, this.$el, { gpuAcceleration: false, placement: this.placement, boundariesPadding: 0, @@ -66,7 +66,7 @@ popper._popper.style.transformOrigin = `center ${ origin }`; } }, - compiled () { + created () { this.$on('on-update-popper', this.update); this.$on('on-destroy-popper', this.destroy); }, diff --git a/src/components/slider/slider.vue b/src/components/slider/slider.vue index bf62ac9..365fa11 100644 --- a/src/components/slider/slider.vue +++ b/src/components/slider/slider.vue @@ -52,6 +52,7 @@ const prefixCls = 'ivu-slider'; export default { + name: 'Slider', components: { InputNumber, Tooltip }, props: { min: { diff --git a/src/index.js b/src/index.js index 23b0933..dbc9949 100644 --- a/src/index.js +++ b/src/index.js @@ -14,7 +14,7 @@ import Checkbox from './components/checkbox'; import Circle from './components/circle'; import Collapse from './components/collapse'; // import DatePicker from './components/date-picker'; -// import Dropdown from './components/dropdown'; +import Dropdown from './components/dropdown'; // import Form from './components/form'; import Icon from './components/icon'; import Input from './components/input'; @@ -64,9 +64,9 @@ const iview = { CheckboxGroup: Checkbox.Group, iCircle: Circle, // DatePicker, - // Dropdown, - // DropdownItem: Dropdown.Item, - // DropdownMenu: Dropdown.Menu, + Dropdown, + DropdownItem: Dropdown.Item, + DropdownMenu: Dropdown.Menu, // iForm: Form, // FormItem: Form.Item, iCol: Col, diff --git a/test/app.vue b/test/app.vue index a7189dd..4278a1f 100644 --- a/test/app.vue +++ b/test/app.vue @@ -38,6 +38,7 @@ li + li { border-left: solid 1px #bbb; padding-left: 10px; margin-left: 10px; }
  • Tooltip
  • Poptip
  • Slider
  • +
  • Dropdown
  • diff --git a/test/main.js b/test/main.js index d987f38..3e7625b 100644 --- a/test/main.js +++ b/test/main.js @@ -116,6 +116,10 @@ const router = new VueRouter({ { path: '/slider', component: require('./routers/slider.vue') + }, + { + path: '/dropdown', + component: require('./routers/dropdown.vue') } ] }); diff --git a/test/routers/dropdown.vue b/test/routers/dropdown.vue index fef3045..0046627 100644 --- a/test/routers/dropdown.vue +++ b/test/routers/dropdown.vue @@ -1,5 +1,5 @@ -- libgit2 0.21.4