18

I'm working on Vue 3, and I need to know how I can import different style sheets for different child components.

For example, I have 3 child components, let's say A and B, and I want to import style sheet X in A and style sheet Z in B.

1 Answer 1

30

Importing CSS in Vue components

If you are setup and using webpack, you should be able to import css directly from inside <style> tags in component files.

// In Component A
<style scoped>
@import "./X.css"
</style>

// In Component B
<style scoped>
@import "./Y.css"
</style>

More info here:

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

2 Comments

Thanks a lot. I would also like to add that it can be imported like this // In Component A <script scoped> import '@/assets/user/css/userapp.css' </script>
Ah yes, i appologise, you mentioned you have vue-cli, this sets up the webpack alias "@" for you :P

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.