2
0
mirror of https://github.com/tenrok/vue2-datepicker.git synced 2026-06-07 07:22:25 +03:00

Make setting the width more dynamic by allowing the use of CSS units (Issue #71)

This commit is contained in:
Rok Vetršek
2018-04-24 19:25:40 +02:00
parent 20a16032e2
commit 5c172602f5
+11 -1
View File
@@ -1,7 +1,7 @@
<template>
<div class="mx-datepicker"
:class="{'disabled': disabled}"
:style="{'width': width + 'px','min-width':range ? (type === 'datetime' ? '320px' : '210px') : '140px'}"
:style="{'width': computedWidth,'min-width':range ? (type === 'datetime' ? '320px' : '210px') : '140px'}"
v-clickoutside="closePopup">
<input name="date"
:disabled="disabled"
@@ -209,6 +209,16 @@ export default {
)
}
return ''
},
computedWidth () {
if (typeof this.width === 'string' && this.width.match(/(px|%|rem|em|ex)$/)) {
return this.width
}
if (typeof this.width === 'string') {
return this.width.replace(/\D/g,'') + 'px'
}
return this.width + 'px'
}
},
methods: {