From dbab8e23e80db39e43d9454f81a65f932ea502ed Mon Sep 17 00:00:00 2001 From: Aicirou <2643053021@qq.com> Date: Tue, 30 Jun 2020 01:49:13 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8Markdown=20displays=20rendered=20html?= =?UTF-8?q?=20by=20default.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/markdown/index.vue | 15 +++++- src/views/common/BreadCrumb.vue | 2 +- src/views/page/GoText.vue | 76 +++++++++++++++++++++++-------- 3 files changed, 71 insertions(+), 22 deletions(-) diff --git a/src/components/markdown/index.vue b/src/components/markdown/index.vue index 48d815e..873170c 100644 --- a/src/components/markdown/index.vue +++ b/src/components/markdown/index.vue @@ -52,10 +52,23 @@ export default { console.log("not mounted init"); } }, + watch: { + source(val) { + if (val) { + this.initWithMd(); + } + }, + }, methods: { + handler(source) { + if (source) { + source = source.replace(/---\n([\s\S]*)---\n/, ""); + } + return source; + }, // 使用 md 初始化 initWithMd() { - this.markedHTML = this.marked(this.source); + this.markedHTML = this.marked(this.handler(this.source)); }, // 使用 url 初始化 async initWithUrl() { diff --git a/src/views/common/BreadCrumb.vue b/src/views/common/BreadCrumb.vue index 81d4b56..61a3eae 100644 --- a/src/views/common/BreadCrumb.vue +++ b/src/views/common/BreadCrumb.vue @@ -1,7 +1,7 @@