在项目中引入富文本编辑器UEditor

在项目中引入富文本编辑器UEditor

什么是UEditor?

UEditor是由百度WEB前端研发部开发的所见即所得的开源富文本编辑器,具有轻量、可定制、用户体验优秀等特点。UEdito下载:下载地址

UEditor使用方法:

第一步:

下载解压,把解压的utf8-php目录复制到项目目录中(一般在public目录下)

第二步:

在html页面引入三个文件,修改src,引入正确的资源路径。

<script type="text/javascript" src="ueditor/ueditor.config.js"></script> 
<script type="text/javascript" src="ueditor/ueditor.all.min.js"></script> 
<script type="text/javascript" src="ueditor/lang/zh-cn/zh-cn.js"></script>
第三步

在html页面,添加一个容器,用于载入富文本编辑器。

<textarea  name="goods_intro" id="goods_intro" style="width: 800px;height: 400"></textarea>
第四步

在js中加入下面一句代码

//将富文本编辑器嵌入到id=goods_intro元素里面
var ue = UE.getEditor('goods_intro');
最后

如果要生成精简富文本编辑器,则需要修改配置文件:ueditor.config.js,中的toolbars配置,里面的toolbars选项是配置工具栏上面显示的内容的,一般不需要修改,如果想修改,则通过如下方式修改(在第四部=步定义ue时顺便给定第二个参数);

UE.getEditor('goods_intro',{
	toolbars: [[
            'fullscreen', 'source', '|', 'undo', 'redo', '|',
            'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
            'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
            'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
            'directionalityltr', 'directionalityrtl', 'indent'
        ]]
});

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值