我有一个没有解决方案的问题,我终于完成了我的应用程序,但现在我不能生成完整的静态网站。在我的例子中,有一个小小的“多参数”博客,我不喜欢Nuxt如何生成路由,因为对于我的导航系统,我需要这样的布局:
Nuxt最后一个版本,node.js最后一个版本
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)
预期的解决办法应是:
mysite.io/
mysite.io/blog/articles-slug
mysite.io/blog-2/articles-slug
也许我搞错了裸体的哲学?有把握
为此,我使用了‘@nuxtjs/路由器’,{ parsePages:'true‘}
我的路由配置如下:
{
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运行时,生成--出错--我得到了很多未找到的页面,因为所看到的路径是错误的:
ERROR Error generating route "/onstep/DownOnStep": This page could not be found 19:05:38
/onstep/download-firmware-onstep是的真正路由
另一件奇怪的事是,我明白:
ERROR Error generating route "/onstep/CosaOnStep": This page could not be found
但至少,只有在这条儿童路线上,我才知道:
√ Generated route "/onstep/cosa-e-onstep"
而html页面是ok...but,他生成两个文件夹:
onstep/cosa-e-onstep和onstep/CosaOnStep
有什么建议吗?
如果可以的话,这就是我的nuxt.config:
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
}
}
}
发布于 2021-09-14 07:20:55
问题解决了,如果我route.js,我必须在nuxt.config.js中声明预录制器的路由路径,如下所示:
generate: {
routes: [ '/',
'/blog/',
'/blog/article1',
]
},
https://stackoverflow.com/questions/69073154
复制相似问题