Import js script and css file within a specific component

Asked

Viewed 144 times

1

Well, I have a template that on certain pages you need specific files to upload. So how do I import a css or js file into the page you need?

Let’s say the page home do not need, but on the page user yes.

1 answer

0

I believe css can be imported this way

<style>
  @import './assets/styles/arquivo.css';
</style>

The script can be like this

<template>
  ... 
</template>

<script>
  export default {
    import * as mylib from '../assets/js/arquivo.js'
  }
</script>
  • It even works, but error, says that the module was not found, but the script plays the role of it. But then it stops working in seconds.

  • the css of the syntax error

Browser other questions tagged

You are not signed in. Login or sign up in order to post.