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

Ton*_*Joe 10 vue.js vue-cli

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

<link rel="stylesheet" href="http://mycssfile.css">
Run Code Online (Sandbox Code Playgroud)

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

cri*_*ris 22

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

<style>
@import "https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/css/bootstrap.min.css";
</style>
Run Code Online (Sandbox Code Playgroud)

  • 我将其添加到 App.vue 中 (3认同)