Skip to content

Commit 5ae7a0b

Browse files
committed
修复数值原子类中存在颜色就无效的问题
1 parent 8333c86 commit 5ae7a0b

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

atomcss-loader.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ module.exports = function(sSource) {
169169
aClassName.forEach(item => {
170170
let sKey;
171171

172-
let bColorFlag = oClassNameMap[item.split('-')[0]] && oClassNameMap[item.split('-')[0]].indexOf('#') != -1;
172+
let bColorFlag = oClassNameMap[item.split('-')[0]] && oClassNameMap[item.split('-')[0]].indexOf('$') == -1 && oClassNameMap[item.split('-')[0]].indexOf('#') != -1;
173173

174174
// 色值类
175175
if (bColorFlag) {
@@ -188,15 +188,16 @@ module.exports = function(sSource) {
188188
// 百分比数值,字重,无需使用单位
189189
if (['.wp', '.hp', '.fw'].includes(sKey)) {
190190
nValue = item.match(/\d+/)[0];
191+
aStyleStr.push(`${item}{${oClassNameMap[sKey]}}`);
191192
} else {
192193
if (bColorFlag) {
193-
nValue = '#' + item.split('-')[1]
194+
nValue = '#' + item.split('-')[1];
195+
aStyleStr.push(`${item}{${oClassNameMap[sKey].replace(/\#/g, nValue)}}`);
194196
} else {
195197
/\d+/.test(item) && (nValue = +item.match(/\d+/)[0]);
198+
aStyleStr.push(`${item}{${oClassNameMap[sKey].replace(/\$/g, nValue)}}`);
196199
}
197200
}
198-
199-
aStyleStr.push(`${item}{${oClassNameMap[sKey].replace(/\$|\#/g, nValue)}}`);
200201
});
201202

202203
// 输出 debug 数据

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-atomcss-loader",
3-
"version": "1.1.7",
3+
"version": "1.1.8",
44
"description": "基于 vue 的按需生成原子类样式的 loader",
55
"homepage": "https://github.com/wujr5/vue-atomcss-loader",
66
"repository": {

0 commit comments

Comments
 (0)