修改markdown展示页面

This commit is contained in:
jmal 2020-03-07 16:17:33 +08:00
parent daae705df5
commit 8b0bff15f2
2 changed files with 11 additions and 5 deletions

View File

@ -98,7 +98,6 @@
}, },
onScroll() { onScroll() {
const scrollTop = this.getScroll(this.el); const scrollTop = this.getScroll(this.el);
console.log(scrollTop)
this.visible = scrollTop >= this.visibilityHeight; this.visible = scrollTop >= this.visibilityHeight;
}, },
handleClick(e) { handleClick(e) {

View File

@ -1,5 +1,5 @@
<template> <template>
<div> <div v-wechat-title="pageTitle">
<al-back-top></al-back-top> <al-back-top></al-back-top>
<div class="content"> <div class="content">
<el-row :gutter="0"> <el-row :gutter="0">
@ -7,6 +7,7 @@
<el-col :xs="24" :sm="22" :md="18" :lg="14" :xl="12"> <el-col :xs="24" :sm="22" :md="18" :lg="14" :xl="12">
<el-main> <el-main>
<mavon-editor <mavon-editor
ref="md"
v-if="!showList" v-if="!showList"
v-model="content" v-model="content"
:subfield="false" :subfield="false"
@ -25,10 +26,12 @@
<script> <script>
import AlBackTop from "@/components/backtop/AlBackTop"; import AlBackTop from "@/components/backtop/AlBackTop";
import markdownApi from '@/api/markdown-api' import markdownApi from '@/api/markdown-api'
export default { export default {
components: { AlBackTop }, components: { AlBackTop },
data() { data() {
return { return {
pageTitle: "文章列表",
showList: true, showList: true,
toolbars: null, toolbars: null,
toolbarsFlag: true, toolbarsFlag: true,
@ -50,6 +53,8 @@
markdownApi.getMarkdown({ markdownApi.getMarkdown({
mark: this.$route.query.mark mark: this.$route.query.mark
}).then((res) => { }).then((res) => {
console.log(res)
this.pageTitle = res.data.name
this.content = res.data.contentText this.content = res.data.contentText
const _this = this const _this = this
setTimeout(function () { setTimeout(function () {
@ -60,10 +65,12 @@
} }
},10) },10)
const doc = document; this.$nextTick(()=>{ // DOM更新之后获取子元素
this.pageTitle = document.querySelector("h1").innerText
})
// const doc = document.querySelector(".v-show-content"); // const doc = document.querySelector(".v-show-content");
console.log(doc) document.addEventListener("scroll", _this.onScroll);
doc.addEventListener("scroll", _this.onScroll);
}) })
} }