为什么配置上的 nuxt.js 全局 css 不起作用? [英] why nuxt.js global css on config is not working?

查看:410
本文介绍了为什么配置上的 nuxt.js 全局 css 不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试将 css 文件放在资产上资产/css/style.css并将其调用到我的 nuxt.config.js但它不起作用我需要使用全局 css 不在范围内的 css

I try to put css files on assets assest/css/style.css and call it to my nuxt.config.js but it is not working i need to use global css not scoped css

有人可以帮我吗?

当我添加 css 时在 nuxt.config.js

when i add css in the nuxt.config.js

   /*
  ** Global CSS
  */
  css: [
      '~assets/css/style.css'
  ],

它不工作?nuxt 版本 2

its not working ? nuxt version 2

推荐答案

我遇到了同样的问题并解决了它,将我的 css 的文件路径放在 css 选项和模块内.下面的示例代码.希望能帮助到你.我也在使用 nuxt-sass-resources-loader 来加载我的全局 sass 文件.

I came across the same issue and solved it putting the file path to my css inside the css options and inside modules. Example code below. Hope it helps. I'm also using nuxt-sass-resources-loader to load my sass files globally.

css: [
  '@/assets/css/reset.css',
  '@/assets/css/main.scss',
],
modules: [
 [
  'nuxt-sass-resources-loader',
  ['./assets/css/main.scss'],
  ['./assets/css/reset.css']
 ]
],

这篇关于为什么配置上的 nuxt.js 全局 css 不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆