kindeditor简单使用

先引入:

    <script src="/static/jquery-3.3.1.min.js"></script>
    <script src="/static/kindeditor-4.1.11-zh-CN/kindeditor/kindeditor-all.js"></script>

基本使用参数:

    $(function () {
        KindEditor.create('#content', {
            width:'1000',// % or px
            height:'3000',//only px
            minWidth:200,//number
            minHeight:400,//number
        });
    })

详细参数:

http://kindeditor.net/docs/option.html

上传文件:

参数:

uploadJson:'/upload_img/'

返回的json格式:

//成功时
{
        "error" : 0,
        "url" : "http://www.example.com/path/to/file.ext"
}
//失败时
{
        "error" : 1,
        "message" : "错误信息"
}

图片上传

 

 

            allowImageUpload:true,//本地图片
            allowImageRemote:true,//远程图片

 

CSRF:

KindEditor.ready(function(K) {
        K.create('#id', {
            extraFileUploadParams: {
                csrfmiddlewaretoken: "{{ csrf_token }}"//csrf
            },
        });
});

 

 

posted @ 2019-03-04 14:33  Neroi  阅读(277)  评论(0编辑  收藏  举报