mirror of
https://github.com/tenrok/vue2-datepicker.git
synced 2026-06-22 13:30:35 +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:
+11
-1
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="mx-datepicker"
|
<div class="mx-datepicker"
|
||||||
:class="{'disabled': disabled}"
|
: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">
|
v-clickoutside="closePopup">
|
||||||
<input name="date"
|
<input name="date"
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
@@ -209,6 +209,16 @@ export default {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
return ''
|
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: {
|
methods: {
|
||||||
|
|||||||
Reference in New Issue
Block a user