fix(compiler): force reset toc when rendering sidebar fixed #181

This commit is contained in:
qingwei.li 2017-06-02 22:12:07 +08:00
parent 9b15d8d577
commit ccf4c7c5cc
No known key found for this signature in database
GPG Key ID: B6DDC2F7AE80B2F4
2 changed files with 7 additions and 0 deletions

View File

@ -135,6 +135,10 @@ export class Compiler {
* Compile sub sidebar
*/
subSidebar (level) {
if (!level) {
this.toc = []
return
}
const currentPath = this.router.getCurrentPath()
const { cacheTree, toc } = this

View File

@ -85,6 +85,9 @@ export function renderMixin (proto) {
const activeEl = getAndActive(this.router, '.sidebar-nav', true, true)
if (loadSidebar && activeEl) {
activeEl.parentNode.innerHTML += this.compiler.subSidebar(subMaxLevel)
} else {
// reset toc
this.compiler.subSidebar()
}
// bind event
this._bindEventOnRendered()