【发布时间】:2021-01-03 08:17:40
【问题描述】:
所以我的想法是我想将 Bootstrap 4.5 实现到 NextJS 并使用它,因为我想覆盖这里显示的变量:https://react-bootstrap.github.io/getting-started/introduction/#customize-bootstrap
我的文件结构在 pages 文件夹中: _app.js
import '../styles/main.scss'
function MyApp({ Component, pageProps }) {
return <Component {...pageProps} />
}
export default MyApp
在我刚刚声明的 main.scss 中:
@import 'custom';
在 custom.scss 中我只是复制了 scss>
$theme-colors: (
"info": tomato,
"danger": teal
);
$nav-link-color: green;
$h1-font-size: 16px * 22.5;
/* import bootstrap to set changes */
@import "~bootstrap/scss/bootstrap";
无论如何,当我想使用像这样的其他变量时:
$theme-colors: (
"info": tomato,
"danger": teal
);
$nav-link-color: $green;
/* import bootstrap to set changes */
@import "~bootstrap/scss/bootstrap";
因为$green已经被bootstrap声明了,我不想重新声明,那么如何正确实现呢?
我也在尝试添加
$nav-link-color: white
例如,但这根本不起作用。有人遇到过这类问题吗?
感谢您的帮助和想法,因为我在 NuxtJS 上也一直在努力解决这个问题,但发现了。但在 NextJS 上,似乎事情进展得并不顺利。我必须一直重新声明东西并声明 BS 变量,然后是我自己的变量,然后再次声明 BS 变量,这似乎有点疯狂。
问候 丁字裤
【问题讨论】:
-
“这根本不起作用”你是什么意思?编译失败?它只是没有显示为白色?
-
在inspector中不显示也不生效
-
那么我们需要minimal reproducible example,否则,我们真的无法帮助您查明您缺少什么。
-
我找到了 $nav-link-color 未生效的原因 - 此变量已弃用。出于某种原因,github 将我引导到旧版本的引导程序。对不起。
-
我在查看了 repo 后更新了我的答案。
标签: reactjs twitter-bootstrap sass next.js