本文摘自PHP中文网,作者little bottle,侵删。
本篇文章的主要内容是教大家如何在Html里插入百度富文本编辑器,感兴趣的朋友可以了解一下,希望能对你有所帮助。在日常工作用,肯定有用到富文本编辑器的时候,富文本编辑器功能强大使用方便,假如你用百度富文本编辑器,首先需要下载好百度编辑器的demo,然后创建ueditor.html文件,引入百度编辑器,然后在html文件内引入,然后再用js实例化编辑器即可。代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <!DOCTYPE html>
< html >
< head >
< title >百度编辑器</ title >
</ head >
< body >
< script type = "text/javascript" charset = "utf-8" src = "ueditor/ueditor.config.js" ></ script >
< script type = "text/javascript" charset = "utf-8" src = "ueditor/ueditor.all.min.js" ></ script >
< script type = "text/javascript" charset = "utf-8" src = "ueditor/lang/zh-cn/zh-cn.js" ></ script >
< script id = "editor" type = "text/plain" name = "gdesc" style = "width:100%;height:350px;" ></ script >
< script type = "text/javascript" >
//实例化编辑器
var ue = UE.getEditor('editor', {});
</ script >
</ body >
</ html >
|
到这里在浏览器打开上面的ueditor.html文件就能看到如下图所示:

这是实例化后的初始编辑器,里面的功能有很多,其中有一部分可能是我们完全用不到的,想定制怎么办呢?别捉急,百度提供了可以定制的功能,将上面实例化编辑器的js代码改为以下代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | <script type= "text/javascript" >
var ue = UE.getEditor( 'editor' , {
toolbars: [
[
'undo' ,
'bold' ,
'underline' ,
'preview' ,
'horizontal' ,
'inserttitle' ,
'cleardoc' ,
'fontfamily' ,
'fontsize' ,
'paragraph' ,
'simpleupload' ,
'insertimage' ,
'attachment' ,
'music' ,
'inserttable' ,
'emotion' ,
'insertvideo' ,
'justifyleft' ,
'justifyright' ,
'justifycenter' ,
'justifyjustify' ,
'forecolor' ,
'fullscreen' ,
'edittip ' ,
'customstyle' ,
'template' ,
]
]
});
</script>
|
刷新ueditor.html页面你就会看到变化了:
阅读剩余部分
相关阅读 >>
Html空格代码怎么写?
Html失效按钮怎么实现
Html文件怎么弄注释
实例介绍Html文本格式化的知识
Html的<basefont>标签
Html sup和sub标签怎么用?Html sup标签和sub标签的定义和用法实例
Html acronym标签怎么用
如何用Html的title属性实现鼠标悬停显示文字
Html source标签怎么用
Html文档由哪几部分组成
更多相关阅读请进入《Html》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » Html怎么插入百度富文本编辑器ueditor