Home  >  Article  >  Web Front-end  >  How to make layui support wangEditor editor

How to make layui support wangEditor editor

尚
forward
2019-11-28 11:36:405154browse

How to make layui support wangEditor editor

How to make layui support wangEditor editor: (Recommended: layui usage tutorial)

wangEditor.min.js module code

比如引用一个123.js
"123.js" 基本配置编辑器模块代码如下
layui.config({
      base: '../lib/wang/' //wangEditor.min.js目录,根据自己存放位置修改
// 比如我的位置:lib/wang/wangEditor.min.js
});

layui.define(function(exports) {
      exports('wangeditor.min', function(){
       demo:demo//这句没用,只是测试
      });
});

//核心来了
layui.use(['layer', 'form','wangeditor.min'], function(){
  var layer = layui.layer
  ,form = layui.form
  ,wang=layui.wangeditor('wang');
  wang.create(); //创建编辑器

//一般在执行按钮操作时使用
 var html = wang.$txt.html(); // 获取内容,更多方法,请wangEditor编辑器官网
 console.log(html);
//一般在执行按钮操作时使用
});

This is the editor

How to make layui support wangEditor editorHow to make layui support wangEditor editor##

//富文本编辑器配置图片上传
  wang.config.uploadImgUrl = '../page/upload/upload.aspx '//调用后台方法
  wang.config.uploadImgFileName = 'file'// 可自己定义
  wang.config.uploadHeaders = {'Accept' : 'text/x-json'};

//后台上传返回代码 
//图片上传失败。Response.Write "error|返回的信息"  根据自己的程序相应输出 

------------成功返回-------------
直接输出图片路径地址:如 "/upload/xxxx.jpg"
------------成功返回-------------
error|返回的信息

The following is simple Introducing the content of the assignment editor, generally used for article editing

edit page


<textarea class="layui-textarea layui-hide//隐藏显示" name="content" id="content">这里是数据库读取的文章内容</textarea>
var editorhtml=$("#content").val() //获取 textarea的内容
wang.$txt.html(editorhtml);// 将内容添加到编辑器里

Full code: https://pan.baidu.com/s/1-cXiYUIgqUfIpZBopEimWg


The above is the detailed content of How to make layui support wangEditor editor. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:layui.com. If there is any infringement, please contact admin@php.cn delete