Ueditor使用方法,手把手教你

来源:互联网 发布:黑马程序员教程百度云 编辑:程序博客网 时间:2024/06/02 20:35
ueditor的使用方法:
第一步:引入    
<!-- 配置文件 --><script type="text/javascript" src="ueditor.config.js"></script><!-- 编辑器源码文件 --><script type="text/javascript" src="ueditor.all.js"></script>

第二步:写表单
传到php里面的时候获取用name所带的值获取:本例htmlspecialchars($_POST['content'])获取。
<form action="server.php" method="post"><!-- 加载编辑器的容器 --><script id="container" name="content" type="text/plain">这里写你的初始化内容</script><input type="submit" value="提交"></form>


第三步:实例化富文本,可以设置想要的工具,配置项里用竖线 '|' 代表分割线,如果分两行,则用[111,1,11],[222,2,222],这样写。
<!-- 实例化编辑器 --><script type="text/javascript">    var ue = UE.getEditor('container', {    toolbars: [    ['fullscreen', 'source', 'undo', 'redo', 'bold']    ],    autoHeightEnabled: true,    autoFloatEnabled: true    });</script>


第四步:设置上传图片等等资源保存的路径,ueditor:上传文件保存路径设置:
D:\wamp64\www\TP\Public\utf8-php\php\config.json
"imagePathFormat": "/TP/Public/Upload/Image/{time}{rand:6}_{filename}", /* 上传保存路径,可以自定义保存路径和文件名格式 */


以下是完整实例:
<!DOCTYPE HTML><html lang="en-US"><head><meta charset="UTF-8"><title>ueditor demo</title><!-- 配置文件 --><script type="text/javascript" src="ueditor.config.js"></script><!-- 编辑器源码文件 --><script type="text/javascript" src="ueditor.all.js"></script></head><body><form action="server.php" method="post"><!-- 加载编辑器的容器 --><script id="container" name="content" type="text/plain">这里写你的初始化内容</script><input type="submit" value="提交"></form><!-- 实例化编辑器 --><script type="text/javascript">    var ue = UE.getEditor('container', {    toolbars: [    ['fullscreen', 'source', 'undo', 'redo', 'bold']    ],    autoHeightEnabled: true,    autoFloatEnabled: true    });    </script></body></html>


0 0
原创粉丝点击