1

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 ?

4
  • Can you provide specific examples. Commented Jan 24, 2017 at 15:05
  • i just want to import some css files. ( e.g. <script type="text/javascript" src="static/assets/js/pages/login.js"></script> ) Commented Jan 25, 2017 at 6:51
  • That can be done in index.html, see this file. Commented Jan 25, 2017 at 6:53
  • yes but it will be available everywhere, what i would like to have is to be available to a specific component Commented Jan 25, 2017 at 7:12

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.