From d9b487e67b95a9ee528dce0009ead47136231efb Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Wed, 31 May 2017 20:42:29 +0800 Subject: [PATCH] fix: can't render toc on first load --- src/core/render/compiler.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/render/compiler.js b/src/core/render/compiler.js index c3547ba77..e12176657 100644 --- a/src/core/render/compiler.js +++ b/src/core/render/compiler.js @@ -44,7 +44,8 @@ export class Compiler { _initRenderer () { const renderer = new marked.Renderer() - const { linkTarget, router, toc, contentBase } = this + const { linkTarget, router, contentBase } = this + const _self = this /** * render anchor tag * @link https://github.com/chjj/marked#overriding-renderer-methods @@ -67,7 +68,7 @@ export class Compiler { const slug = slugify(text) const url = router.toURL(router.getCurrentPath(), { id: slug }) nextToc.slug = url - toc.push(nextToc) + _self.toc.push(nextToc) return `${text}` }