如何将 cdn css 文件添加到 Vue Cli 3 项目? [英] How to add cdn css file to Vue Cli 3 project?

查看:22
本文介绍了如何将 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>

这篇关于如何将 cdn css 文件添加到 Vue Cli 3 项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆