如何在nuxt js项目中包含css

时间:2017-08-16 07:32:27

标签: javascript css

In my nuxt.config.js I added this:

module.exports = {
    head: {
        css: [
            'bulma/css/bulma.css',
             "HTML_design/libs/fancybox/jquery.fancybox.css",
             "HTML_design/libs/owl-carousel/assets/owl.carousel.css",
             "HTML_design/style.css",
            {src: "~/assets/css/style.css", lang: 'css'}
        ]

    }
};

我使用了多种连接方法,但没有人帮助

在我的packege.json

{
  "name": "mynuxt",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "dev": "nuxt",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "axios": "^0.16.2",
    "bulma": "^0.5.1",
    "nuxt": "^1.0.0-rc4",
    "vue-style-loader": "^3.0.1"
  }
}

但是在浏览器的控制台中,我看不到连接的css文件。我该怎么办?

enter image description here

3 个答案:

答案 0 :(得分:1)

因为您的配置错误。请查看以下示例:

module.exports = {
    head: {
        // NOT here
    },
    css: [
        'bulma/css/bulma.css',
        '~/assets/css/style.css'
    ]
}

答案 1 :(得分:0)

您可以查看资源标签以查看它是否已加载。

答案 2 :(得分:0)

版本的nuxt必须小于^ 1.0.0-rc4