修正不能匹配全部CSS单位的问题
This commit is contained in:
parent
04af0d3497
commit
b3a7b78f5b
|
@ -70,9 +70,9 @@ export default {
|
||||||
*/
|
*/
|
||||||
containerStyle() {
|
containerStyle() {
|
||||||
const style = {}
|
const style = {}
|
||||||
if (/^[\d]+(\.\d+)?$/.test(this.width)) { // Matches `100`, `'100'`
|
if (/^[\d]+(\.[\d]+)?$/.test(this.width)) { // Matches `100`, `'100'`
|
||||||
style.width = `${this.width}px`
|
style.width = `${this.width}px`
|
||||||
} else if (/^[\d]+(\.\d+)?([a-z]{2}|%)$/.test(this.width)) { // Matches `100px`, `100rem`, `70%`, etc
|
} else if (/^[\d]+(\.[\d]+)?([a-z]{2,4}|%)$/.test(this.width)) { // Matches `100px`, `100rem`, `70%`, etc
|
||||||
style.width = `${this.width}`
|
style.width = `${this.width}`
|
||||||
}
|
}
|
||||||
return style
|
return style
|
||||||
|
|
Loading…
Reference in New Issue