文档:https://www.npmjs.com/package/mavon-editor
安装依赖
npm install mavon-editor --save
示例
/**
* https://www.npmjs.com/package/mavon-editor
*
* npm install mavon-editor --save
*/
import { mavonEditor } from 'mavon-editor';
import 'mavon-editor/dist/css/index.css';
/**
*
* 事件
* save
* change
*/
export default {
name: '',
props: [],
components: {
mavonEditor,
},
data() {
return {
};
},
computed: {},
methods: {
// 将图片上传到服务器,返回地址替换到md中
async handleImgAdd(pos, file) {
let form = new FormData();
form.append('file', file);
const res = await this.$Http.postUploadFile(form);
console.log(res);
this.$refs.md.$img2Url(pos, res.data.url);
},
},
created() {},
};
参考 vue中使用markdown编辑器