diff --git a/src/core/render/compiler.js b/src/core/render/compiler.js index aad4db907b..fc140f193a 100644 --- a/src/core/render/compiler.js +++ b/src/core/render/compiler.js @@ -191,11 +191,12 @@ export class Compiler { const currentPath = this.router.getCurrentPath() const { cacheTree, toc } = this - toc[0] && toc[0].ignoreAllSubs && toc.splice(0, toc.length) + toc[0] && toc[0].ignoreAllSubs && toc.splice(0) toc[0] && toc[0].level === 1 && toc.shift() - toc.forEach((node, i) => { - node.ignoreSubHeading && toc.splice(i, 1) - }) + + for (let i = 0; i < toc.length; i++) { + toc[i].ignoreSubHeading && toc.splice(i, 1) && i-- + } const tree = cacheTree[currentPath] || genTree(toc, level)