Use ueditor Rich Text Editor and vueueditor in vue
I recently used the rich text editor when I was working on the background management system. Finally, select ueditor, which is used by my project.Vue + vuex + vue-router + webpack + elementUITo build the framework,
1, download the UEditor official website of the latest jsp version of the package, download decompress the package to get a utf8-jsp folder, which contains the following content:
2. Change this folder to ueditor and move it to the static folder in your project. modify the content in the ueditor. config. js folder, for example:
3. Write child components
<Template> <div: id = "id" type = "text/plain"> </div> </template> <script> import '.. /.. /.. /static/ueditor. config. js 'import '.. /.. /.. /static/ueditor. all. min. js 'import '.. /.. /.. /static/ueditor/lang/zh-cn/zh-cn.js 'import '.. /.. /.. /static/ueditor. parse. min. js 'export default {name: 'ue', data () {return {editor: null }}, props: {defaultMsg: {type: String, default: 'Enter the content '}, Config: {type: Object}, id: {type: String, default: 'UE $ {Math. random (0,100)} '}}, mounted () {this. $ nextTick () => {this. editor = UE. getEditor (this. id, this. config); // initialize UE this. editor. addListener ("ready", () => {this.editor.exe cCommand ('insertml', this. defaultMsg); this. editor. focus () // After the UE is loaded, place the content. })}, Methods: {getUEContent () {// return this. editor. getContent ()}, clearContent () {// clear the editor content return this.editor.exe cCommand ('cleardoc ') ;},}, beforeDestroy () {// when the component is destroyed, to destroy the UEditor instance if (this. editor! = Null & this. editor. destroy) {this. editor. destroy () ;}}</script> <style scoped> </style>
4. Use it in the parent component
<UE :config="configEditor" :id="ue1" ref="ue" :defaultMsg="val"></UE>
5. After the configuration is completed, the backend configuration item http Error will be prompted during image uploading, and an upload error will be prompted during file uploading. Here, do not declare that after the ueditor is configured on the front end, it needs to work with the back end, and then configure the ueditor. config. change the serverUrl prefix in js to your own backend Access Request Path.
ServerUrl: "unified request address"
Summary
The above section describes how to use the ueditor Rich Text Editor in the vue. I hope it will help you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!