done select

pull/165/head
tjz 2018-02-26 22:19:48 +08:00
parent 4ecbecab41
commit ae378d8676
8 changed files with 16 additions and 32 deletions

View File

@ -19,13 +19,13 @@ const md = {
下拉选择器 下拉选择器
## 何时使用 ## 何时使用
- 弹出一个下拉菜单给用户选择操作用于代替原生的选择器或者需要一个更优雅的多选器时 - 弹出一个下拉菜单给用户选择操作用于代替原生的选择器或者需要一个更优雅的多选器时
- 当选项少时少于 5 建议直接将选项平铺使用 [Radio](/components/radio/) - 当选项少时少于 5 建议直接将选项平铺使用 [Radio](#/cn/components/radio/) 是更好的选
## 代码演示`, ## 代码演示`,
us: `# Select us: `# Select
Select component to select value from options. Select component to select value from options.
## When To Use ## When To Use
- A dropdown menu for displaying choices - an elegant alternative to the native \`<select>\` element. - A dropdown menu for displaying choices - an elegant alternative to the native \`<select>\` element.
- Utilizing [Radio](/components/radio/) is recommended when there are fewer total options (less than 5). - Utilizing [Radio](#/us/components/radio/) is recommended when there are fewer total options (less than 5).
`, `,
} }
export default { export default {

View File

@ -16,7 +16,6 @@ Select with tags, transform input to tag (scroll the menu)
style="width: 100%" style="width: 100%"
@change="handleChange" @change="handleChange"
placeholder="Tags Mode" placeholder="Tags Mode"
@popupScroll="test"
> >
<a-select-option v-for="i in 25" :key="(i + 9).toString(36) + i">{{(i + 9).toString(36) + i}}</a-select-option> <a-select-option v-for="i in 25" :key="(i + 9).toString(36) + i">{{(i + 9).toString(36) + i}}</a-select-option>
</a-select> </a-select>
@ -27,9 +26,6 @@ export default {
handleChange(value) { handleChange(value) {
console.log(`selected ${value}`); console.log(`selected ${value}`);
}, },
test(e) {
console.log(e)
}
} }
} }
</script> </script>

View File

@ -453,7 +453,7 @@
padding-left: 0; // Override default ul/ol padding-left: 0; // Override default ul/ol
list-style: none; list-style: none;
max-height: 250px; max-height: 250px;
overflow: auto; // overflow: auto;
&-item-group-list { &-item-group-list {
margin: 0; margin: 0;

View File

@ -6,7 +6,6 @@ import { getSelectKeys, preventDefaultEvent } from './util'
import { cloneElement } from '../_util/vnode' import { cloneElement } from '../_util/vnode'
import BaseMixin from '../_util/BaseMixin' import BaseMixin from '../_util/BaseMixin'
import { getSlotOptions } from '../_util/props-util' import { getSlotOptions } from '../_util/props-util'
import addEventListener from '../_util/Dom/addEventListener'
export default { export default {
name: 'DropdownMenu', name: 'DropdownMenu',
@ -33,12 +32,6 @@ export default {
mounted () { mounted () {
this.$nextTick(() => { this.$nextTick(() => {
this.scrollActiveItemToView() this.scrollActiveItemToView()
const { $refs, $listeners } = this
if ($listeners.popupScroll) {
console.log($refs.menuContainer)
this.menuContainerHandler = addEventListener($refs.menuContainer,
'scroll', ()=>{console.log(111)})
}
}) })
this.lastVisible = this.$props.visible this.lastVisible = this.$props.visible
}, },
@ -49,12 +42,6 @@ export default {
} }
}, },
}, },
beforeDestroy () {
if (this.menuContainerHandler) {
this.menuContainerHandler.remove()
this.menuContainerHandler = null
}
},
updated () { updated () {
const props = this.$props const props = this.$props
if (!this.prevVisible && props.visible) { if (!this.prevVisible && props.visible) {
@ -174,12 +161,13 @@ export default {
render () { render () {
const renderMenu = this.renderMenu() const renderMenu = this.renderMenu()
this.prevVisible = this.visible this.prevVisible = this.visible
const { popupFocus } = this.$listeners const { popupFocus, popupScroll } = this.$listeners
return renderMenu ? ( return renderMenu ? (
<div <div
style={{ overflow: 'auto' }} style={{ overflow: 'auto' }}
onFocus={popupFocus} onFocus={popupFocus}
onMousedown={preventDefaultEvent} onMousedown={preventDefaultEvent}
onScroll={popupScroll}
ref='menuContainer' ref='menuContainer'
> >
{renderMenu} {renderMenu}

View File

@ -172,7 +172,7 @@ export default {
const mirrorNode = this.getInputMirrorDOMNode() const mirrorNode = this.getInputMirrorDOMNode()
if (inputNode.value) { if (inputNode.value) {
inputNode.style.width = '' inputNode.style.width = ''
inputNode.style.width = `${mirrorNode.clientWidth}px` inputNode.style.width = `${mirrorNode.clientWidth + 10}px`
} else { } else {
inputNode.style.width = '' inputNode.style.width = ''
} }
@ -383,7 +383,7 @@ export default {
}, },
onPlaceholderClick (e) { onPlaceholderClick (e) {
if (this._focused) { if (this.openStatus) {
e.stopPropagation() e.stopPropagation()
} }
if (this.getInputDOMNode()) { if (this.getInputDOMNode()) {
@ -651,12 +651,10 @@ export default {
return null return null
}, },
inputClick (e) { inputClick (e) {
if (this._focused) { if (this.openStatus) {
if (this.openStatus) { e.stopPropagation()
e.stopPropagation() } else {
} else { this._focused = false
this._focused = false
}
} }
}, },
inputBlur (e) { inputBlur (e) {
@ -719,6 +717,7 @@ export default {
attrs: { attrs: {
...(inputElement.data.attrs || {}), ...(inputElement.data.attrs || {}),
disabled: props.disabled, disabled: props.disabled,
value: this.inputValue,
}, },
domProps: { domProps: {
value: this.inputValue, value: this.inputValue,

View File

@ -15,12 +15,12 @@ Dropdown | done
Divider | done Divider | done
notification | done notification | done
message | done message | done
Select | done
Carousel Carousel
Mention Mention
Input | done |select完成后补全demo Input | done |select完成后补全demo
InputNumber InputNumber
AutoComplete AutoComplete
Select
Upload Upload
Form Form
Calendar Calendar

View File

@ -7,6 +7,7 @@ export { default as checkbox } from 'antd/checkbox/demo/index.vue'
export { default as grid } from 'antd/grid/demo/index.vue' export { default as grid } from 'antd/grid/demo/index.vue'
export { default as icon } from 'antd/icon/demo/index.vue' export { default as icon } from 'antd/icon/demo/index.vue'
export { default as input } from 'antd/input/demo/index.vue' export { default as input } from 'antd/input/demo/index.vue'
export { default as select } from 'antd/select/demo/index.vue'
export { default as menu } from 'antd/menu/demo/index.vue' export { default as menu } from 'antd/menu/demo/index.vue'
export { default as pagination } from 'antd/pagination/demo/index.vue' export { default as pagination } from 'antd/pagination/demo/index.vue'
export { default as popconfirm } from 'antd/popconfirm/demo/index.vue' export { default as popconfirm } from 'antd/popconfirm/demo/index.vue'

View File

@ -7,7 +7,7 @@ const AsyncComp = () => {
} }
} }
export default [ export default [
{ path: '/:lang/components/:name/:demo?', component: Demo }, { path: '/:lang?/components/:name/:demo?', component: Demo },
{ path: '/:lang?/test/:name/:demo?', component: AsyncComp }, { path: '/:lang?/test/:name/:demo?', component: AsyncComp },
{ path: '/*', redirect: '/cn/components/menu' }, { path: '/*', redirect: '/cn/components/select' },
] ]