2
0
mirror of https://github.com/tenrok/vue2-datepicker.git synced 2026-06-03 10:14:09 +03:00

Merge pull request #82 from ObSeSSeN/changeable_width

Make setting the width more dynamic by allowing the use of CSS units
This commit is contained in:
xiemengxiong
2018-04-25 09:41:13 +08:00
committed by GitHub
+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: {