使用 Vue3 和 postcss 的 Fullcalendar 自定义 css
我正在使用 vue3 的 fullcalendar。我想更改全日历中按钮和文本的颜色。
vue 版本
"vue": "^3.2.26",
我收到错误
语法错误:错误:PostCSS 插件 postcss-custom-properties 需要 PostCSS 8。
我按照 fullcalendar 文档中提到的步骤操作。
fullcalendar-vars.css
:root {
--fc-border-color: green;
--fc-button-text-color: #ff0000;
}
我已经安装了以下软件包
"postcss": "^8.4.7",
"postcss-calc": "^8.2.4",
"postcss-custom-properties": "^12.1.4",
"postcss-loader": "^6.2.1",
在根目录添加了 postcss.config.js
module.exports = {
plugins: [
require('postcss-custom-properties')({
preserve: false, // completely reduce all css vars
importFrom: [
'client/fullcalendar-vars.css' // look here for the new values
]
}),
require('postcss-calc')
]
}
和我的 vue.config.js 如下
const path = require("path");
module.exports = {
pages: {
index: {
entry: "./client/main.js",
},
},
outputDir: path.resolve(__dirname, "./client/dist"),
};
另外我我想知道,我需要对 vue.config.js 进行任何更改吗?
I am using fullcalendar with vue3. I want to change change colors for button and text in fullcalendar.
vue version
"vue": "^3.2.26",
I am getting error
Syntax Error: Error: PostCSS plugin postcss-custom-properties requires
PostCSS 8.
I am following steps mentioned in fullcalendar documentation.
fullcalendar-vars.css
:root {
--fc-border-color: green;
--fc-button-text-color: #ff0000;
}
I have installed following packages
"postcss": "^8.4.7",
"postcss-calc": "^8.2.4",
"postcss-custom-properties": "^12.1.4",
"postcss-loader": "^6.2.1",
Added postcss.config.js at root
module.exports = {
plugins: [
require('postcss-custom-properties')({
preserve: false, // completely reduce all css vars
importFrom: [
'client/fullcalendar-vars.css' // look here for the new values
]
}),
require('postcss-calc')
]
}
And my vue.config.js as follow
const path = require("path");
module.exports = {
pages: {
index: {
entry: "./client/main.js",
},
},
outputDir: path.resolve(__dirname, "./client/dist"),
};
Also I would like to know, Do I need make any changes in vue.config.js?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
PostCSS 错误
Vue CLI 脚手架项目 已经包含 PostCSS (包括
postcss< /code>、
postcss-calc
和postcss-loader
),因此您无需在项目中安装它。这里唯一需要的依赖是postcss-custom-properties
。要解决 PostCSS 错误,您应该卸载错误添加的 PostCSS 依赖项:
从头开始
要在 Vue CLI 脚手架项目中为 FullCalendar 设置自定义颜色:
安装
postcss-custom-properties
与:使用以下 PostCSS 配置创建
postcss.config.js
:使用以下 CSS 创建
fullcalendar-vars.css
:注意:对此文件的更改不会热重新加载,因此开发服务器必须重新启动才能反映任何更新。
启动 Vue CLI 开发服务器:
demo< /a>
PostCSS error
Vue CLI scaffolded projects already include PostCSS (including
postcss
,postcss-calc
, andpostcss-loader
), so you don't need to install it in your project. The only dependency needed here ispostcss-custom-properties
.To resolve the PostCSS error, you should uninstall the PostCSS dependencies that you had mistakenly added:
Starting from scratch
To setup custom colors for FullCalendar in a Vue CLI scaffolded project:
Install
postcss-custom-properties
with:Create
postcss.config.js
with the following PostCSS configuration:Create
fullcalendar-vars.css
with the following CSS:Note: Changes to this file are not hot-reloaded, so the dev server must be restarted to reflect any updates.
Start the Vue CLI dev server with:
demo