Join the Stack Overflow Community
Stack Overflow is a community of 6.9 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

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 ?

share|improve this question
    
Can you provide specific examples. – Saurabh Jan 24 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> ) – iNDicator Jan 25 at 6:51
    
That can be done in index.html, see this file. – Saurabh Jan 25 at 6:53
    
yes but it will be available everywhere, what i would like to have is to be available to a specific component – iNDicator Jan 25 at 7:12

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.