在Vue2中安装vditor,
npm install vditor --save
使用vditor代码如下,
<template>
<div id="vditor" name="description"></div>
</template>
<script>
import Vditor from "vditor";
import "vditor/src/assets/scss/index.scss";
export default {
data() {
return {
contentEditor: "",
};
},
mounted() {
this.contentEditor = new Vditor("vditor", {
height: 360,
toolbarConfig: {
pin: true,
},
cache: {
enable: false,
},
after: () => {
this.contentEditor.setValue("hello,Vditor");
},
});
},
};
</script>