From 106574aadd0bab5355b2a8f4acf59b69f7a25916 Mon Sep 17 00:00:00 2001 From: mxie <15623530290@163.com> Date: Wed, 25 Apr 2018 09:52:55 +0800 Subject: [PATCH] width allow css units --- datepicker/index.vue | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/datepicker/index.vue b/datepicker/index.vue index 425828a..36843d8 100644 --- a/datepicker/index.vue +++ b/datepicker/index.vue @@ -211,14 +211,10 @@ export default { return '' }, computedWidth () { - if (typeof this.width === 'string' && this.width.match(/(px|%|rem|em|ex)$/)) { - return this.width + if ((typeof this.width === 'string' && /^\d+$/.test(this.width)) || typeof this.width === 'number') { + return this.width + 'px' } - if (typeof this.width === 'string') { - return this.width.replace(/\D/g,'') + 'px' - } - - return this.width + 'px' + return this.width } }, methods: {