【问题标题】:Nuxt js app build still loading constantlyNuxt js 应用程序构建仍在不断加载
【发布时间】:2021-08-03 16:25:37
【问题描述】:

我用 Nuxt.js 制作了 2 个新应用

他们与npm run dev合作得很好

但是使用npm run buildnpm run generate 创建的静态文件正在不断加载

控制台显示“加载资源失败:服务器响应状态为 404 ()”

我不知道如何解决它。

我的 nuxt.config.js

export default {
  // Disable server-side rendering: https://go.nuxtjs.dev/ssr-mode
  ssr: false,

  // Target: https://go.nuxtjs.dev/config-target
  target: 'static',

  // Global page headers: https://go.nuxtjs.dev/config-head
  head: {
    title: 'À Bicyclette',
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: '' }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
    ]
  },

  // Global CSS: https://go.nuxtjs.dev/config-css
  css: [
  ],

  // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
  plugins: [
  ],

  // Auto import components: https://go.nuxtjs.dev/config-components
  components: true,

  // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
  buildModules: [
  ],

  // Modules: https://go.nuxtjs.dev/config-modules
  modules: [
    // https://go.nuxtjs.dev/pwa
    '@nuxtjs/pwa',
  ],

  // PWA module configuration: https://go.nuxtjs.dev/pwa
  pwa: {
    manifest: {
      lang: 'en'
    }
  },

  // Build Configuration: https://go.nuxtjs.dev/config-build
  build: {
  }
}

【问题讨论】:

  • 请分享您的 nuxt.config.js 文件。
  • 您的 nuxt.config 对我来说看起来不错,您是否尝试过 npm run generate 并在本地使用 http-server 提供服务?
  • 是的,我已经使用 Xamp 和真实服务器运行了这些文件
  • 如果你确实打开了一个新页面,它可能与一些生命周期挂钩有关。我知道到底发生了什么,但我们需要/pacifique 的代码。顺便说一句,既然你用的是static,这里就不用yarn build了,yarn generate就够了。
  • 感谢您的反馈!我收到了您的反馈的问题。 Nuxt 应用程序需要在服务器的根目录才能工作(文件之间的链接问题)。

标签: nuxt.js


【解决方案1】:

感谢您的反馈!我收到了您的反馈的问题。 Nuxt 应用需要位于服务器的根目录才能工作(文件之间的链接问题)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-30
    • 2019-01-16
    • 1970-01-01
    • 2021-06-27
    • 1970-01-01
    • 2020-04-17
    相关资源
    最近更新 更多