简体   繁体   中英

How to include CSS in page in Nuxt.js project

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'}
        ]

    }
};

I've used several methods of connection, but none has helped.

In my package.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"
  }
}

But in the console in my browser, I can not see the connected css files. What do I do?

在此处输入图片说明

Because your configuration is wrong. Check the example below:

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

您可以查看资源选项卡以查看它是否已加载。

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM