正好要做一个文章管理,记录一下遇到的坑

1. 引入富文本编辑器

1
2
3
4
5
6
7
8
var layedit = layui.layedit;
layedit.set({
uploadImage: {
url: '/v1/openApi/uploadImage' //接口url
,type: '' //默认post
}
});
var index = layedit.build('demo');

这里我接入了图片上传

图片上传需要定义好接口

1
2
3
4
5
6
7
8
{
"code": 0 //0表示成功,其它失败
,"msg": "" //提示信息 //一般上传失败后返回
,"data": {
"src": "图片路径"
,"title": "图片名称" //可选
}
}

2. 富文本编辑器回显

1
<textarea id="demo" style="display: none;" name="article" autocomplete="off" placeholder="内容" th:text="*{article}" ></textarea>

这里我使用了 th:text

3. 最终效果
20221116193413