@johnpaul.blick
В Nuxt.js можно подключить CSS стили несколькими способами.
1 2 3 4 5 |
export default { css: [ '@/assets/global.css' ] } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<template>
<div class="example">Example component</div>
</template>
<script>
import styles from '~/components/example.module.css'
export default {
name: 'ExampleComponent',
data() {
return {
styles
}
}
}
</script>
<style module>
.example {
color: red;
}
</style>
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<template>
<div class="example">Example component</div>
</template>
<script>
import '~/components/example.scss'
export default {
name: 'ExampleComponent'
}
</script>
<style lang="scss">
.example {
color: red;
}
</style>
|
После этого, стили будут автоматически добавлены в проект.
@johnpaul.blick
Additional alternatives to importing CSS in Nuxt.js include:
1 2 3 |
<template> <div style="color: red;">Example component</div> </template> |
1 2 |
# Example for Tailwind CSS npm install tailwindcss |
Then, you can either import the CSS file globally in nuxt.config.js or directly into your components.
1 2 3 4 5 6 7 8 9 10 11 |
<template>
<div class="example">Example component</div>
</template>
<script>
import '~/components/example.css'
export default {
name: 'ExampleComponent'
}
</script>
|
Remember to include appropriate styles in the CSS file.
These methods offer flexibility in managing CSS styles depending on your project's requirements. Choose the best approach that suits your needs.