Include external CSS library in only one Vue component
10,232
Import css file in style tag of App.js
<style>
@import './static/css/style.css';
</style>
![Linx](https://i.stack.imgur.com/dmRkk.jpg?s=256&g=1)
Author by
Linx
Updated on August 04, 2022Comments
-
Linx almost 2 years
I have a Vue app with many components. Currently I have Font-Awesome included in the head of the index.html file however only ONE page, or component, actually needs it. Is it possible to move it to the component itself so that it only loads when it's needed?
MOVE THIS
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
TO THIS
<template></template> <link rel="stylesheet" href="../../static/css/font-awesome-4.7.0/css/font-awesome-min.css"></link> <script> export default { name: 'SingleComponent', data: function() { return{} } } </script> <style scoped> </style>
I've tried downloading Font-Awesome and adding a link tag in the component like above ^^^^ I don't get any errors but the icons still don't work.
-
josue over 2 yearshow to add this in vue? <link rel="stylesheet" href="maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/…">
-
-
Linx over 6 yearsNo I have many components but only one that needs Font-Awesome
-
Hybrid web dev almost 5 yearsThis isn't an answer.