From e26e1f50ab4fb7b95ccb31edcc09aefcb4868e19 Mon Sep 17 00:00:00 2001 From: mxie <15623530290@163.com> Date: Thu, 11 Oct 2018 10:03:42 +0800 Subject: [PATCH] feat: add prop `appendToBody` --- README.md | 2 + README.zh-CN.md | 4 +- demo/index.js | 3 +- src/directives/clickoutside.js | 1 + src/index.vue | 76 ++++++++++++++++++++++++++++------ src/utils/index.js | 22 ++++++++++ test/index.spec.js | 10 +++++ 7 files changed, 104 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 035f9cd..5dc6a67 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,8 @@ export default { | disabled | Boolean | false | Disable the component | | placeholder | String | | input placeholder text | | width | String/Number | 210 | input size | +| append-to-body | Boolean | false | append the popup to body | +| popupStyle | Object | | popup style(override the top, left style) | | not-before | String/Date | '' | Disable all dates before new Date(not-before) | | not-after | String/Date | '' | Disable all dates after new Date(not-after) | | disabled-days | Array/function| [] | Disable Days | diff --git a/README.zh-CN.md b/README.zh-CN.md index e0269ad..7bf4c91 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -80,7 +80,9 @@ export default { | editable | Boolean | true | 如果是false, 用户不能手动输入更新日期 | disabled | Boolean | false | 禁用组件 | placeholder | String | | 输入框placeholder -| width | String/Number | 210 | 设置宽度 +| width | String/Number | 210 | 设置宽度 +| append-to-body | Boolean | false | 弹出层放到body下面 +| popup-style | Object | | 弹出层的样式(可以覆盖left,top样式) | not-before | String/Date | '' | 禁止选择这个时间之前的时间 | not-after | String/Date | '' | 禁止选择这个时间之前=后的时间 | disabled-days | Array/function| [] | 自定义禁止的日期 diff --git a/demo/index.js b/demo/index.js index 3013a0d..03438e3 100644 --- a/demo/index.js +++ b/demo/index.js @@ -47,7 +47,7 @@ new Vue({ // eslint-disable-line render (h) { const example1 = { 'base': '', - 'range': '', + 'range': '', 'month': '', 'year': '', 'time': '' @@ -64,6 +64,7 @@ new Vue({ // eslint-disable-line v-model="value4" lang="en" type="datetime" + appendToBody format="YYYY-MM-DD hh:mm:ss a" :time-picker-options="{ start: '00:00', diff --git a/src/directives/clickoutside.js b/src/directives/clickoutside.js index 3217d8e..2de0485 100644 --- a/src/directives/clickoutside.js +++ b/src/directives/clickoutside.js @@ -4,6 +4,7 @@ export default { el['@clickoutside'] = e => { if ( !el.contains(e.target) && + !(vnode.context.popupElm && vnode.context.popupElm.contains(e.target)) && binding.expression && vnode.context[binding.expression] ) { diff --git a/src/index.vue b/src/index.vue index 4f63c5d..ebea410 100644 --- a/src/index.vue +++ b/src/index.vue @@ -44,7 +44,7 @@
@@ -106,7 +106,7 @@