Vue.js Nuxt应用程序在使用嵌套路由时冻结

Vue.js Nuxt应用程序在使用嵌套路由时冻结,vue.js,vuejs2,nuxt.js,Vue.js,Vuejs2,Nuxt.js,在索引(主页)中,如果单击按钮并导航到: http://localhost:3000/browse/songs/new 它冻结了浏览器,并且没有响应为空白的白色页面 但是,如果我手动输入此url,它会工作 我的页面目录结构: --browse --songs --new index.vue browse.vue index.vue 我在github上发现了一个问题,但它对我没有帮助 看起来您的问题实际上与您链接到的github上的问题有关 如

在索引(主页)中,如果单击按钮并导航到:

http://localhost:3000/browse/songs/new
它冻结了浏览器,并且没有响应为空白的白色页面

但是,如果我手动输入此url,它会工作

我的页面目录结构:

--browse
    --songs
        --new
            index.vue

browse.vue
index.vue
我在github上发现了一个问题,但它对我没有帮助


看起来您的问题实际上与您链接到的github上的问题有关

如果我理解正确,您的页面目录如下:

|-browse (folder)
|  |-songs (folder)
|    |-new (folder)
|      index.vue (file)
|-browse.vue (file)
|-index.vue (file)
这将导致nuxt的混乱,因为您基本上有两种不同的东西试图成为同一个东西,您的“浏览”文件夹和您的“浏览”文件

您应该这样尝试:

|-browse (folder)
|  |index.vue (file) //this replaces your browse.vue file and can be found at http://localhost:3000/browse
|  |-songs (folder)
|    |-new (folder)
|      index.vue (file) //this can be found at http://localhost:3000/browse/songs/new
|-index.vue (file)
如果上述打破了nuxt子项安排,则以下操作似乎有效

|-browse (folder)
|  |index.vue (file) 
|  |-songs (folder)
|    |-index.vue 
|    |-new (folder)
|      index.vue (file) 
|-browse.vue
|-index.vue (file)
由于路由嵌套,要查找每个路由的
,需要将其包含在每个级别的index.vue中。该文件可以包含以下内容:

//browse-index.vue && browse-songs-index.vue
<template>
  <div>
    <nuxt-child/>
  </div>
</template>
//browse-index.vue&&browse-songs-index.vue

但它能让孩子的链条保持活力

看起来您的问题实际上与您链接到的github上的问题相关

如果我理解正确,您的页面目录如下:

|-browse (folder)
|  |-songs (folder)
|    |-new (folder)
|      index.vue (file)
|-browse.vue (file)
|-index.vue (file)
这将导致nuxt的混乱,因为您基本上有两种不同的东西试图成为同一个东西,您的“浏览”文件夹和您的“浏览”文件

您应该这样尝试:

|-browse (folder)
|  |index.vue (file) //this replaces your browse.vue file and can be found at http://localhost:3000/browse
|  |-songs (folder)
|    |-new (folder)
|      index.vue (file) //this can be found at http://localhost:3000/browse/songs/new
|-index.vue (file)
如果上述打破了nuxt子项安排,则以下操作似乎有效

|-browse (folder)
|  |index.vue (file) 
|  |-songs (folder)
|    |-index.vue 
|    |-new (folder)
|      index.vue (file) 
|-browse.vue
|-index.vue (file)
由于路由嵌套,要查找每个路由的
,需要将其包含在每个级别的index.vue中。该文件可以包含以下内容:

//browse-index.vue && browse-songs-index.vue
<template>
  <div>
    <nuxt-child/>
  </div>
</template>
//browse-index.vue&&browse-songs-index.vue

但它能让孩子的链条保持活力

在codesandbox或github上创建复制。如果没有codesandbox或github上的codecreate复制,就无法判断。没有代码是不可能分辨的,但是有了这个结构,我就有问题了。在|-browse中,index.vue我有两个组件应该加载到子页面中。在browseindex.vue中,我有一个,但它不会在songs/new/index.vue中呈现这些组件。我该怎么办?是的,那会是个问题。我认为您的文件夹嵌套太多,无法与nuxt child一起正常工作,这可能会导致您最初的问题。就我所知,要让nuxt儿童工作,儿童应该只有一层深。如果需要这种结构,可以使用常规的组件结构。或者发布一些代码给@Aldarund看,他是这类事情的大师。
常规组件结构是什么?
?我的意思是普通组件。因此,如果您希望/browse/songs/new看起来像/browse,但有一些附加内容,请在browse-index.vue和browse-songs-new-index.vue中使用一个组件,并在该组件之后添加附加内容(我想是新歌)。想想别的。。。我将编辑答案。使用新结构(browse.vue)再次冻结,但使用此结构,我遇到了问题。在|-browse中,index.vue我有两个组件应该加载到子页面中。在browseindex.vue中,我有一个,但它不会在songs/new/index.vue中呈现这些组件。我该怎么办?是的,那会是个问题。我认为您的文件夹嵌套太多,无法与nuxt child一起正常工作,这可能会导致您最初的问题。就我所知,要让nuxt儿童工作,儿童应该只有一层深。如果需要这种结构,可以使用常规的组件结构。或者发布一些代码给@Aldarund看,他是这类事情的大师。
常规组件结构是什么?
?我的意思是普通组件。因此,如果您希望/browse/songs/new看起来像/browse,但有一些附加内容,请在browse-index.vue和browse-songs-new-index.vue中使用一个组件,并在该组件之后添加附加内容(我想是新歌)。想想别的。。。我将编辑answer.It,并使用新结构(browse.vue)再次冻结