您的位置:首页 > 产品设计 > UI/UE

百度UEditor编译器中添加HTML最快捷的办法

2017-11-07 09:41 323 查看
之前写了一篇关于百度百度UEditor编译器中添加HTML的博客:

http://blog.csdn.net/yingjia11/article/details/78443319

我的html代码是这样的:

<script id="editor" type="text/plain" style="width: 100%; height: 50%;"></script>
<code id="content" style="display:none;">
${content}
</code>js代码是这样的
var editor = new UE.ui.Editor();
editor.render('editor');
editor.addListener( 'ready', function(edt) {
var content_old = $('#content').html();
if(content_old!=''){
editor.execCommand('insertHtml', content_old);
}
});但后来看评论说,可以直接把代码放script标签中,我就尝试地去掉code标签:
<script id="editor" type="text/plain" style="width: 100%; height: 50%;">
${content}
</script>
<!-- <code id="content" style="display:none;">
${content}
</code> -->然后js里面去掉
// editor.addListener( 'ready', function(edt) {
// var content_old = $('#content').html();
// if(content_old!=''){
// editor.execCommand('insertHtml', content_old);
// }
// }); 这部分,发现果然也可以,但是反复操作后发现,怎么前后空格行越来越多了



折腾了半天,原来是因为默认把script中的全部内容放上去了,所以html里面这样写就好了

<script id="editor" type="text/plain" style="width: 100%; height: 50%;">${content}</script>中间不能加任何空格或者换行!
搞定!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  UEditor html