Как подключить css в nuxt.js?

Пользователь

от jeromy_ruecker , в категории: JavaScript , 9 месяцев назад

Как подключить css в nuxt.js?

Facebook Vk Ok Twitter LinkedIn Telegram Whatsapp

1 ответ

Пользователь

от margaret , 9 месяцев назад

@jeromy_ruecker 

There are two ways to connect CSS in Nuxt.js:

  1. Add styles to the head section of the Nuxt.js layout file: Create a CSS file (e.g., styles.css) in the assets directory. Open the layouts/default.vue file and add the CSS file to the head section:
  2. Use the CSS inside a component: Create a CSS file (e.g., styles.css) in the assets directory. Open a component file (e.g., MyComponent.vue) and import the CSS file using the style tag: The scoped attribute adds a unique identifier to the CSS selectors, scoping the styles to the component only.


Remember to use the correct path for the CSS file when using the ~ shortcut in Nuxt.js.