pnpm install tailwindcss postcss-import postcss-nested autoprefixer
export default defineConfig({
// ...
extraPostCSSPlugins: [require("tailwindcss"), require("autoprefixer")],
// ...
});
/* 根目录下global.less引入 */
@import 'tailwindcss/base';
@import 'tailwindcss/components';
@import 'tailwindcss/utilities';
原因是我们使用了tailwindcss ,默认情况会有tailwindcss的默认属性代码块内我们发现 background-color: transparent; 这个是默认属性导致的
button,
[type="button"],
[type="reset"],
[type="submit"] {
-webkit-appearance: button;
background-color: transparent;
background-image: none;
}
<style > button,
[type="button"],
[type="reset"],
[type="submit"] {
-webkit-appearance: button;
background-color: transparent;
background-image: none;
}
修改文件 tailwind.config.js 添加corePlugins对象,并设置preflight为false
module.exports = {
...
...
corePlugins: {
preflight: false
}
}