no message

Former-commit-id: 27b76acdd44c7ea3cc0355a55d8cc1945adc54c3
Former-commit-id: 82f8695364c45bdbc8eb3379e6a4e7cc354de250
Former-commit-id: b5c05e19486bacb03b784ad27ab22d3968124cfe
This commit is contained in:
李杨
2018-02-24 09:17:20 +08:00
parent 93f6f5636c
commit a10a08aafa
2 changed files with 59 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
<template>
<Container type="ghost">
<el-row :gutter="10">
<el-col :span="12">
<el-card>
<PageHeader
slot="header"
title="代码高亮"
url="https://github.com/chjj/marked">
</PageHeader>
<pre>{{mdSource}}</pre>
</el-card>
</el-col>
<el-col :span="12">
<el-card>
<template slot="header">解析结果</template>
<div class="markdown-body" v-html="markedHTML"></div>
</el-card>
</el-col>
</el-row>
</Container>
</template>
<script>
import marked from 'marked'
import highlight from 'highlight.js'
export default {
data () {
return {
mdSource: '',
markedHTML: ''
}
},
async mounted () {
this.mdSource = await this.getReadme(this.url)
this.markedHTML = marked(this.mdSource, {
highlight: (code) => {
return highlight.highlightAuto(code).value
}
})
},
methods: {
async getReadme () {
const data = await this.$axios.get('/static/markdownFiles/demo/baseMarkdowmFile.md')
return data
}
}
}
</script>

View File

@@ -109,6 +109,16 @@ export const menu = {
requiresAuth: true
},
component: resolve => { require(['@/pages/demo/components/markdown/demoHighlight.vue'], resolve) }
},
{
title: '自定义渲染',
icon: 'file-o',
path: 'marked/demoRender',
name: 'demo-components-markdown-demoRender',
meta: {
requiresAuth: true
},
component: resolve => { require(['@/pages/demo/components/markdown/demoRender.vue'], resolve) }
}
]
},