Vue如何整合mavon-editor編輯器(markdown編輯和預(yù)覽)
簡介
說明
本文介紹Vue如何使用markdown編輯器。
mavon-editor是目前比較主流的markdown編輯器,本文介紹它的使用方法。
官網(wǎng)網(wǎng)址
https://github.com/hinesboy/mavonEditor
安裝mavon-editor依賴
npm install mavon-editor -P
注冊(cè)mavon-editor編輯器
在main.js中加入如下內(nèi)容:
import mavonEditor from 'mavon-editor' import 'mavon-editor/dist/css/index.css' Vue.use(mavonEditor);
使用編輯功能
代碼
<template>
<div class="app-container">
<el-button type="primary" @click="saveGuideData()">發(fā)布</el-button>
<el-form :model="guideDetail" :rules="rules" ref="dataForm" label-width="100px">
<el-form-item label="內(nèi)容" prop="content">
<mavon-editor v-model="guideDetail.content"></mavon-editor>
</el-form-item>
</el-form>
</div>
</template>
<script>
import {saveGuide} from "@/api/guide";
export default {
name: "GuideEdit",
data() {
return {
guideDetail: {
content: ''
},
rules: {
content: [
{required: true, message: '請(qǐng)輸入內(nèi)容', trigger: 'blur'}
]
},
}
},
methods: {
saveGuideData() {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
saveGuide(this.guideDetail.content).then(() => {
this.$notify({
title: '成功',
message: '創(chuàng)建成功',
type: 'success',
duration: 2000
})
})
}
})
}
}
}
</script>
<style scoped>
</style>結(jié)果展示

使用預(yù)覽功能
代碼
<template>
<div class="app-container">
<mavon-editor v-model="guideDetail.content"
:subfield="false"
:defaultOpen="'preview'"
:editable="false"
:toolbarsFlag="false"
>
</mavon-editor>
</div>
</template>
<script>
export default {
name: "GuideDetail",
data() {
return {
guideDetail: {
content: '### 這是第三級(jí)標(biāo)題\n' +
'這里是正文'
},
}
}
}
</script>
<style scoped>
</style>結(jié)果展示

到此這篇關(guān)于Vue整合mavon-editor編輯器(markdown編輯和預(yù)覽)的文章就介紹到這了,更多相關(guān)Vue整合mavon-editor編輯器內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Vue3+TypeScript實(shí)現(xiàn)Docx/Excel預(yù)覽組件
這篇文章主要為大家詳細(xì)介紹了如何使用Vue3+TypeScript實(shí)現(xiàn)Docx/Excel預(yù)覽組件,文中的示例代碼講解詳細(xì),有需要的小伙伴可以參考下2024-04-04
vue swipeCell滑動(dòng)單元格(仿微信)的實(shí)現(xiàn)示例
這篇文章主要介紹了vue swipeCell滑動(dòng)單元格(仿微信)的實(shí)現(xiàn)示例,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-09-09
淺談實(shí)現(xiàn)在線預(yù)覽PDF的幾種解決辦法
這篇文章主要介紹了淺談實(shí)現(xiàn)在線預(yù)覽PDF的幾種解決辦法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2020-08-08
Vue Element校驗(yàn)validate的實(shí)例
這篇文章主要介紹了Vue Element校驗(yàn)validate的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2020-09-09
Vue+axios使用FormData方式向后端發(fā)送數(shù)據(jù)
在前后端分離的項(xiàng)目中經(jīng)常使用到Vue+axios通過FormData的方式向后端發(fā)送表單數(shù)據(jù),下面就來介紹一下如何實(shí)現(xiàn),感興趣的可以了解一下2023-09-09
vue3+TypeScript+vue-router的使用方法
本文詳細(xì)講解了vue3+TypeScript+vue-router的使用方法,文中通過示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-01-01

