简体   繁体   English

我无法在导航栏上使用 css 样式(使用 sass)

[英]I can't use css styles on my navbar (using sass)

I'm starting to learn by my own and I tried for the first time to use sass in order to get more clean my code, having everything on sections.我开始自己学习,我第一次尝试使用 sass 来使我的代码更干净,将所有内容都放在部分中。 So the problem is when I try to give some styles to the navbar, I don't know why when I write code it doesn't apply.所以问题是当我尝试为导航栏提供一些样式时,我不知道为什么当我编写代码时它不适用。 Maybe is because I'm not linking correctly or just using bad the sass compiler.也许是因为我没有正确链接或者只是使用了不好的 sass 编译器。

The best option to help me is take a look into my repository where I started to build this project to practice.帮助我的最佳选择是查看我的存储库,在那里我开始构建此项目以进行练习。 I really hope could help me because I want to create differents sections like navbar, body, articles, footer using sass and give them styles.我真的希望能帮助我,因为我想使用 sass 创建不同的部分,如导航栏、正文、文章、页脚并赋予它们样式。

https://github.com/Shylex96/test-portfolio https://github.com/Shylex96/test-portfolio

Edit: After a long search about this issue I see there is a problem with "use" and I have to change rules or something like that, but still don't know.编辑:对这个问题进行了长时间的搜索后,我发现“使用”存在问题,我必须更改规则或类似的内容,但仍然不知道。

Replace @use with @import in your scss files.将 scss 文件中的 @use 替换为 @import。

Try updating your \\util\\style.scss like below:尝试更新您的 \\util\\style.scss,如下所示:

@import '../globals/';
@import '../components/';

Save and compile them then copy the resulting css files to dist folder if they weren't copied automatically.保存并编译它们,如果它们没有被自动复制,则将生成的 css 文件复制到 dist 文件夹。

Update the stylesheet link in your index.html file to:将 index.html 文件中的样式表链接更新为:

<link rel="stylesheet" type="text/css" href="dist/style.css">

It should be "dist/style.css" not "/dist/style.css"它应该是“dist/style.css”而不是“/dist/style.css”

FINALLY!!最后!! I solved it and I'm going to commit what helps me if someone have same issues..我解决了它,如果有人有同样的问题,我将承诺对我有帮助的东西..

I had to reinstall node.js, install gulp, and change "about_Execution_Policies" from windows.. when I did, I could finally install gulp correctly and then I install again sass.我不得不重新安装 node.js,安装 gulp,并从 Windows 更改“about_Execution_Policies”……当我这样做时,我终于可以正确安装 gulp,然后我再次安装 sass。 Of course, I just converted all the changes that people told me about into the first ones I had.当然,我只是将人们告诉我的所有更改都转换为我的第一个更改。 I created a new file called gulpfie.js and two more files: .gitignore and .gitattributes我创建了一个名为 gulpfie.js 的新文件和另外两个文件:.gitignore 和 .gitattributes

So, If someone need it, can check the changes here: https://github.com/Shylex96/test-portfolio所以,如果有人需要它,可以在这里检查更改: https : //github.com/Shylex96/test-portfolio

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM