因为我这里只要求有基本的富文本功能,限制图片大小,限制可输入传文本字数,没有过多的要求,所以没有配置工具栏,如有需要请自行搜索配置项,一搜一大把,这里就不做阐述啦。
安装依赖
npm install vue2-editor --save
安装ts声明,项目没使用ts就不安装
npm install @types/vue2-editor --save
index.vue
<vue-editor ref="editor" class="editor" v-model="detail.content" :disabled="!editing"
useCustomImageHandler @image-added="handleImageAdded">
</vue-editor>
<span style="float: right;margin-right: 20px;">
{
{innerLength}}/200
</span>
index.ts
import { VueEditor } from 'vue2-editor';
@Component({
components: {
VueEditor
}
})
private content = ''
private editing = '' //富文本内容是否可编辑,依实际情况判断
private textLength = 0 //纯文字字数
get innerLength () {
retur