vuepress icon indicating copy to clipboard operation
vuepress copied to clipboard

侧边栏配置 collapsable: true, 但第一个始终会展开

Open xuoutput opened this issue 4 years ago • 1 comments

  • [ ] I confirm that this is an issue rather than a question.

Bug report

Steps to reproduce

https://vuepress.vuejs.org/zh/theme/default-theme-config.html#%E5%A4%9A%E4%B8%AA%E4%BE%A7%E8%BE%B9%E6%A0%8F

按 多个侧边栏来配置

    sidebar: {
      '/foo/': [
{
 title: 'DD'
collapsable: true
children: []
}
      ],

      '/bar/': [
{
 title: 'DD'
collapsable: true
children: []
}

      ],

      // fallback
      '/': [
        '',        /* / */
        'contact', /* /contact.html */
        'about'    /* /about.html */
      ]
    }

What is expected?

What is actually happening?

Other relevant information

  • Output of npx vuepress info in my VuePress project:

xuoutput avatar Jan 27 '21 04:01 xuoutput

我也有同样的疑问,直到我看到了侧边栏分组的示例,这里面有个initialOpenGroupIndex

在“父项”里将initialOpenGroupIndex置为-1,那么子项初始化时都是折叠的。不设置initialOpenGroupIndex的话(默认值0),将默认展示第一个子项。

最后,希望官方将侧边栏相关的字段放到配置这块加以说明。

liawnliu avatar Jul 01 '22 17:07 liawnliu