mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
feat(wxs): style.wxs support camel case attr (#4281)
This commit is contained in:
parent
e3b7ed997e
commit
ac50898519
@ -2,6 +2,16 @@
|
|||||||
var object = require('./object.wxs');
|
var object = require('./object.wxs');
|
||||||
var array = require('./array.wxs');
|
var array = require('./array.wxs');
|
||||||
|
|
||||||
|
function kebabCase(word) {
|
||||||
|
var newWord = word
|
||||||
|
.replace(getRegExp("[A-Z]", 'g'), function (i) {
|
||||||
|
return '-' + i;
|
||||||
|
})
|
||||||
|
.toLowerCase()
|
||||||
|
|
||||||
|
return newWord;
|
||||||
|
}
|
||||||
|
|
||||||
function style(styles) {
|
function style(styles) {
|
||||||
if (array.isArray(styles)) {
|
if (array.isArray(styles)) {
|
||||||
return styles
|
return styles
|
||||||
@ -21,7 +31,7 @@ function style(styles) {
|
|||||||
return styles[key] != null && styles[key] !== '';
|
return styles[key] != null && styles[key] !== '';
|
||||||
})
|
})
|
||||||
.map(function (key) {
|
.map(function (key) {
|
||||||
return [key, [styles[key]]].join(':');
|
return [kebabCase(key), [styles[key]]].join(':');
|
||||||
})
|
})
|
||||||
.join(';');
|
.join(';');
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user