mirror of
https://github.com/kuaifan/dootask.git
synced 2026-01-20 07:58:12 +00:00
37 lines
740 B
Vue
37 lines
740 B
Vue
<template>
|
|
<div class="markdown-preview-nostyle" v-html="html"></div>
|
|
</template>
|
|
|
|
<script>
|
|
import marked from '../../config/marked';
|
|
export default {
|
|
name: 'markdown-preview-nostyle',
|
|
props: {
|
|
initialValue: {
|
|
type: String,
|
|
default: ''
|
|
},
|
|
},
|
|
data() {
|
|
return {
|
|
html: '',
|
|
};
|
|
},
|
|
mounted() {
|
|
this.translateMarkdown();
|
|
},
|
|
methods: {
|
|
translateMarkdown() {
|
|
this.html = marked(this.initialValue, {
|
|
sanitize: false,
|
|
}).replace(/href="/gi, 'target="_blank" href="');
|
|
},
|
|
},
|
|
watch: {
|
|
initialValue() {
|
|
this.translateMarkdown();
|
|
}
|
|
}
|
|
};
|
|
</script>
|