简体   繁体   English

调用 Nuxt JS 静态文件

[英]Calling Nuxt JS static files

I try to call my css files that i have in static directory but i get an error message我尝试调用静态目录中的 css 文件,但收到一条错误消息

/* style not found */

this is my own code这是我自己的代码

    mode: 'spa',
  /*
  ** Headers of the page
  */
  server: {
    port: 8000, // default: 3000
    host: '0.0.0.0' // default: localhost
  },
  head: {
    title: process.env.npm_package_name || '',
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: process.env.npm_package_description || '' }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
      { rel: 'stylesheet', href: 'static/css/theme/layout.css' }
    ]
  },

and i do npm run dev我做npm run dev

For Javascript it is对于 Javascript,它是

export default {
    ...
    head: {
        script: [{src: "/js/example.js"}]
    }
    ...
}

for this reason nuxt have it's own.出于这个原因,nuxt 有它自己的。 In your case :在你的情况下:

css: [
  './static/css/theme/layout.css'
],

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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