请问一下,为什么我这里使用了bootsrap的样式,但是没有效果呢?

来源:5-1 为项目选择样式库

慕慕0439991

2020-07-14

图片描述张老师,您好,在我这里用了bootstrap的样式,但是好像没有效果,

import React from 'react';
import 'bootstrap/dist/css/bootstrap.min.css';

export default function HomePage() {
  return (
    <div className="App container-fluid">
      <div className="row">
        <div className="col-3 bg-light left-panel">
          <h1>this is the left this is the left this is the left</h1>
        </div>
        <div className="col-9 bg-primary right-panel">
          <h1>this is the right</h1>
        </div>
      </div>
    </div>
  );
}

请问一下,这个该怎么解决呢?

写回答

2回答

张轩

2020-07-16

同学你好 看了你的提问和代码 原来你使用的  electron-react-boilerplate,我的项目中都使用的 create-react-app ,它的webpack 配置直接支持 css 文件的 import。但是你采用的脚手架好像不支持直接 css 文件的 import,这里有一个解决方案,正是你需要的,也是在它们的 issue 中找到的。

https://github.com/electron-react-boilerplate/electron-react-boilerplate/issues/468

// 在 app.global.css 中,使用波浪线
@import '~semantic-ui-css/semantic.min.css';

同学你在 github 提问的非常棒,英文水平不错,我很喜欢这种尝试主动寻找答案的行为,给你点赞!

1
1
慕慕0439991
好的,感谢张老师的帮助和鼓励! 我会继续努力学习的!
2020-07-17
共1条回复

张轩

2020-07-14

同学你好 请问 bootstrap 是否安装成功了呢?可以查看一下 node_modules 下是否有对应这个路径的文件 “bootstrap/dist/css/bootstrap.min.css”

0
5
慕慕0439991
回复
张轩
这是我使用的源代码, 链接:https://pan.baidu.com/s/1XCd8pt8OSD9fqAkWHaXNgw 提取码:44xn
2020-07-15
共5条回复

2024更新 Electron+React+七牛云实战跨平台桌面应用

开发一款自动云同步的 Markdown 文件管理软件

1252 学习 · 463 问题

查看课程