iNDicator
iNDicator

Reputation: 534

Issue importing css/js file in vuejs 2 component

I have the following .vue component file:

<template>
....

</template>
<script>
export default { /* stuff here*/}
</script>
<style>

</style>

Now i would like to include some css/js (provided by the template on themeforest) files for this component only. including them within the tag doesnt seem to work. any idea what wrong ?

Upvotes: 1

Views: 1218

Answers (1)

castle
castle

Reputation: 83

Docs on how to do this: https://vue-loader.vuejs.org/en/start/spec.html#src-imports.

<template src="./template.html"></template>
<style src="./style.css" scoped></style>
<script src="./script.js"></script>

Note the use of scoped attribute. One can also use the module attribute instead of scoped. More details

Upvotes: 1

Related Questions