vuetify.js - 有没有办法排除 Vuetify 的 _typography.sass?
问题描述
我最近开始使用 Vuetify,我正在努力解决类名冲突。这.title
是特别的,因为在使用 Vuetify 之前我已经.title
在很多地方使用过。只是因为这个名字太笼统了。我找到了一种覆盖它们的方法,但仍然不理想,因为技术上你不能.title
在任何地方使用。这很烦人。我发现样式文件来自 Vuetify 的 _typography.sacss: file link。
我想知道是否有办法通过排除这个文件vue.config.js
,甚至可以重命名/删除类.title
?
解决方案
找到了解决方案。使用postcss-prefix-selector
. 这个想法来自https://github.com/vuetifyjs/vuetify/issues/8530
安装 postcss-prefix-selector
$ npm install postcss-prefix-selector
在vue.config.js
const prefixer = require('postcss-prefix-selector');
module.exports = {
css: {
sourceMap: true,
loaderOptions: {
/* solving the problem Vuetify's built-in style .v-application .title and others causing conflicts
* with existing title classes. */
postcss: {
plugins: [
prefixer({
prefix: '',
transform: function(prefix, selector, prefixedSelector) {
if (selector.startsWith('.v-application')) {
console.log(selector, prefixedSelector);
}
if (selector === '.v-application .title') {
return `.v-application .v-title`;
}
else if (selector === '.v-application .headline') {
return `.v-application .v-headline`;
}
else if (selector === '.v-application .caption') {
return `.v-application .v-caption`;
}
else if (selector === '.v-application .overline') {
return `.v-application .v-overline`;
}
else if (selector === '.v-application p') {
return `.v-application .v-p`;
}
else {
return prefixedSelector;
}
}
})
]
}
},
},
};
推荐阅读
- jestjs - “toHaveStyleRule”在 Jest(React Typescript)中不起作用,但是 toHaveStyle 可以
- android - 我在 Android 和 ios 中都使用了`MPAndroidChart`,但得到了这个区别。有人可以帮我解决这个问题吗?
- javascript - 如何在 expressJs 中使用 module.exports?
- javascript - Next JS : 在 dom 渲染时加载屏幕
- github - Github Projects 测试版计划何时发布?
- c - Linux 系统调用实现 - Linux 内核
- python - Artifactory 7.x - pypi 代理错误
- ffmpeg - Adafruit I2S MEMS 麦克风的 FFMPEG 录制音频存在问题
- python - 在OpenCV中确定拼接后的重叠区域
- swiftui - 如何让 SwiftUI 在 iPad 上显示整个垂直内容?