如何将 cdn css 文件添加到 Vue Cli 3 项目?

问题描述:

我试图在我的 vue-cli-3 项目中包含一个 cdn 外部 css 文件,所以我在 public/index.html 文件中添加了 css 文件,如下所示:

I'm trying to include a cdn external css file in my vue-cli-3 project, so I added the css file in the public/index.html file like this:

<link rel="stylesheet" href="http://mycssfile.css">

但是生成的 index.html 文件中不包含 css.这曾经适用于 vuejs2,我不明白为什么它不适用于 vuejs3.知道问题是什么吗?谢谢

But the css is not included in the generated index.html file. this used to work in vuejs2, I don't understand why it doesn't work with vuejs3. Any idea what the problem is? thanks

很简单.在您的 main.vue 上添加以下内容

It is simple. On your main.vue add the following

<style>
  @import "https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/css/bootstrap.min.css";
</style>