My quick VUE workflow for a HTML/CSS template.
Create a project
vue create hello-world
Using Pre-Processors
yarn add sass-loader node-sass
Add scripts on mounted
Expected Usage
1 2 3 4 |
mounted(){ // font awesome script this.addScript("https://kit.fontawesome.com/a076d05399.js", 'js'); }, |
method
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
methods: { addScript(url, type='js') { if(type === 'js'){ let script = document.createElement("script"); script.setAttribute("src", url); document.head.appendChild(script); } if(type === 'css'){ let script = document.createElement("style"); script.setAttribute("rel", 'text/css'); script.setAttribute("type", 'stylesheet'); script.setAttribute("href", url); document.head.appendChild(script); } } } |