首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Nuxt生成不生成路由html文件

Nuxt生成不生成路由html文件
EN

Stack Overflow用户
提问于 2021-09-06 10:38:11
回答 1查看 767关注 0票数 1

我有一个没有解决方案的问题,我终于完成了我的应用程序,但现在我不能生成完整的静态网站。在我的例子中,有一个小小的“多参数”博客,我不喜欢Nuxt如何生成路由,因为对于我的导航系统,我需要这样的布局:

Nuxt最后一个版本,node.js最后一个版本

代码语言:javascript
运行
复制
index
blog
|-article one (child of blog)
|-article two (child of blog)
|-other pages (child of blog)
other blog
|-article one (child of other blog)
|-article two (child of other blog)
|-other pages (child of other blog)

预期的解决办法应是:

代码语言:javascript
运行
复制
mysite.io/

mysite.io/blog/articles-slug
    
mysite.io/blog-2/articles-slug

也许我搞错了裸体的哲学?有把握

为此,我使用了‘@nuxtjs/路由器’,{ parsePages:'true‘}

我的路由配置如下:

代码语言:javascript
运行
复制
 {
            path: '/',
            name: 'Home',
            component: Home
          },
          {
            path: '/onstep',
            name: 'OnStep',
            component: OnstepMain,
            children: [
              { path: 'cosa-e-onstep', name: 'Cosa è OnStep', component: CosaOnStep },
              { path: 'configurazioni-possibili-di-onstep', name: 'Configurazioni Possibili', component: ConfOnStep },
              { path: 'moduli-necessari-per-la-scheda', name: 'Moduli Necessari', component: ModuliNecessari },
              { path: 'scelta-del-driver-per-motori-passo-passo', name: 'Scelta Del Driver Per Motori Passo Passo', component: SceltaDriver },
              { path: 'funzionamento-scelta-motori-passo-passo', name: 'Scelta e Funzinamento dei Motori Passo Passo', component: SceltaStepper },
              { path: 'calcolo-step-grado-montatura-eq-o-azm', name: 'Calcolo degli step/grado di una montatura EQ o AZM', component: CalcoloStep },
              { path: 'montare-la-scheda', name: 'Montare la Scheda', component: MontaScheda },
              { path: 'prepariamoci-a-scaricare-il-firmware', name: 'Preprariamo il PC', component: PreparaPC },
              { path: 'download-configurazione-firmware-onstep', name: 'Impostare il firmware di OnStep', component: FwOnstep },
              { path: 'configurazione-firmware-wifi', name: 'Impostare il firmware del WiFi', component: FwWiFi }, 
              { path: 'download-firmware-onstep', name: 'Download Firmware OnStep', component: DwOnstep },
            ]
          },
        ]
      })

当我执行npm运行时,生成--出错--我得到了很多未找到的页面,因为所看到的路径是错误的:

代码语言:javascript
运行
复制
 ERROR  Error generating route "/onstep/DownOnStep": This page could not be found                                                                                                                 19:05:38  

/onstep/download-firmware-onstep是的真正路由

另一件奇怪的事是,我明白:

代码语言:javascript
运行
复制
 ERROR  Error generating route "/onstep/CosaOnStep": This page could not be found  

但至少,只有在这条儿童路线上,我才知道:

代码语言:javascript
运行
复制
√ Generated route "/onstep/cosa-e-onstep" 

而html页面是ok...but,他生成两个文件夹:

onstep/cosa-e-onstep和onstep/CosaOnStep

有什么建议吗?

如果可以的话,这就是我的nuxt.config:

代码语言:javascript
运行
复制
const path = require('path')

export default {
  // Target: https://go.nuxtjs.dev/config-target
  target: 'static',
  ssr: 'true',

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

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

  css: [
    '~assets/styles/tailwind.css', 
],

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

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

  // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
  buildModules: [
    ['@nuxtjs/router', { parsePages: 'true' }],
    // https://go.nuxtjs.dev/eslint
    '@nuxtjs/eslint-module',
    // https://go.nuxtjs.dev/stylelint
    '@nuxtjs/stylelint-module',
    // https://go.nuxtjs.dev/tailwindcss
    '@nuxtjs/tailwindcss',

    '@nuxtjs/sitemap',
  ],

  // Modules: https://go.nuxtjs.dev/config-modules
  modules: [
    'nuxt-purgecss',
  ],

  purgeCSS: {
    mode: 'postcss',
    enabled: (process.env.NODE_ENV === 'production')
  },


  sitemap: {
    hostname: 'https://stefanotesla.it',
    gzip: true,
  },


  // Build Configuration: https://go.nunpm run devxtjs.dev/config-build
  build: {
    postcss: {
      plugins: {
        'postcss-import': {},
        tailwindcss: path.resolve(__dirname, './tailwind.config.js'),
        'postcss-nested': {}
      }
    },
    preset: {
      stage: 1 // see https://tailwindcss.com/docs/using-with-preprocessors#future-css-featuress
    }
}
}
EN

回答 1

Stack Overflow用户

发布于 2021-09-14 07:20:55

问题解决了,如果我route.js,我必须在nuxt.config.js中声明预录制器的路由路径,如下所示:

代码语言:javascript
运行
复制
      generate: {
    routes: [ '/', 
              '/blog/',
              '/blog/article1',
            ]
  },
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69073154

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档