Subscribe on changes!

内置vclass指令,自动生成全局css,不用再写css

avatar
Apr 27th 2022

What problem does this feature solve?

前端项目中有非常多的样式其实是重复的,可以通过添加新的指令,在编译代码时自动生成全局的css;开发人员甚至可以不用再写css,编译后生成全局的css,相同的属性只会生成一条css,进一步缩小vue项目的打包大小

What does the proposed API look like?

<div v-class="pd-10 fs-20 fw-700"></div>

自动生成global.css

.pd-10 { padding: 10px; }
.fs { font-size: 20px }
.fw-700 { font-weight: 700 }
avatar
Apr 27th 2022

scss

avatar
Apr 27th 2022

scss

scss只是css预处理,还是需要自己写,或者全局定义一些class;最理想的是像写内联style一样写class,自动生成css

avatar
Apr 27th 2022

maybe you can use windicss. vite has corresponding plugin vite-plugin-windicss

avatar
Apr 27th 2022

What you need is: tailwind windicss unocss

avatar
Apr 27th 2022

有一个css库就是类似于这样的写法

avatar
Apr 27th 2022

It's out of the scope of Vue core. As @kikyous pointed out there are already plenty to third party tools for your use case.