Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add cdn css file to Vue Cli 3 project?

Tags:

vue.js

vue-cli

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">

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

like image 910
Toni Joe Avatar asked Jul 12 '18 21:07

Toni Joe


People also ask

How do I add CSS files to Vue 3?

Importing CSS in Vue components If you are setup and using webpack, you should be able to import css directly from inside <style> tags in component files. More info here: https://cli.vuejs.org/guide/css.html.

How do I add CDN to Vue?

You can add cdn styles/scripts directly to the ./index. html or ./public/index. html in [email protected].

How do I add CSS to Vue?

In Vue. js, we can add an inline style to our element by binding the style attribute in the HTML tag. For reference, :style is shorthand for v-bind:style . Inline styling can be done in two ways: using object syntax or array syntax.


1 Answers

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>
like image 85
cris Avatar answered Oct 11 '22 19:10

cris