vue-froala-wysiwyg 富文本编辑器

近期需要在vue3项目上做一个富文本编辑器,找了很多插件组件,最终决定用 froala。虽然不是免费的,但是功能实在是太强大了。

froala 文档:https://www.froala.com/wysiwyg-editor/docs/overview

froala 官方demo: https://www.froala.com/wysiwyg-editor/examples

下面介绍在vue3.中如何安装使用froala。

Step1:

  froala 依赖于jQuery。所以要安装jQuery;

yarn add jquery 
或者
npm install jquery --save

  froala 依赖于 babel-runtime。所以也要安装。

yarn add [email protected]
或者
npm install [email protected] --save

Step2:

   安装froala-editor 和  vue-froala-wysiwyg。

yarn add froala or npm install froala-editor --save  
yarn add vue
-froala-wysiwyg or npm i vue-froala-wysiwyg --save

Step3:

在main.js 里引入jQuery。

import jquery from 'jquery'
window.jquery = window.$ = jquery

在main.js里引入froala相关的文件并且进行相应的配置。

require('froala-editor/js/froala_editor.pkgd.min')
require('froala-editor/css/froala_editor.pkgd.min.css')
require('font-awesome/css/font-awesome.css')
require('froala-editor/css/froala_style.min.css')

import VueFroala from 'vue-froala-wysiwyg'
Vue.use(VueFroala)

Step4 : 

这个时候就可以使用froala这个组件啦~。

在某个.vue文件中:



其他相关的config配置 和 事件操作 可以查看文档。

 

你可能感兴趣的:(vue-froala-wysiwyg 富文本编辑器)