💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# 百度编辑器 ### 下载 <http://apps.bdimg.com/libs/ueditor/1.4.3.1/ueditor.all.js> ### 使用 ``` <pre class="calibre14">``` <span class="token"><</span>script id<span class="token">=</span><span class="token4">"container"</span> name<span class="token">=</span><span class="token4">"content"</span> type<span class="token">=</span><span class="token4">"text/plain"</span><span class="token">></span> 这里写你的初始化内容 <span class="token"><</span><span class="token">/</span>script<span class="token">></span> <span class="token"><</span>script type<span class="token">=</span><span class="token4">"text/javascript"</span> src<span class="token">=</span><span class="token4">"ueditor.config.js"</span><span class="token">></span><span class="token"><</span><span class="token">/</span>script<span class="token">></span> <span class="token"><</span>script type<span class="token">=</span><span class="token4">"text/javascript"</span> src<span class="token">=</span><span class="token4">"ueditor.all.js"</span><span class="token">></span><span class="token"><</span><span class="token">/</span>script<span class="token">></span> <span class="token"><</span>script type<span class="token">=</span><span class="token4">"text/javascript"</span><span class="token">></span> var editor<span class="token">=</span> UE<span class="token2">.</span><span class="token1">getEditor</span><span class="token2">(</span><span class="token4">'container'</span><span class="token2">,</span><span class="token2">{</span> initialFrameHeight<span class="token2">:</span><span class="token3">250</span><span class="token2">,</span> allowDivTransToP<span class="token2">:</span><span class="token3">false</span><span class="token6">//div保留</span> <span class="token2">}</span><span class="token2">)</span><span class="token2">;</span> <span class="token"><</span><span class="token">/</span>script<span class="token">></span> var content <span class="token">=</span> editor<span class="token2">.</span><span class="token1">getContent</span><span class="token2">(</span><span class="token2">)</span><span class="token2">;</span><span class="token6">//获取内容</span> editor<span class="token2">.</span><span class="token1">setContent</span><span class="token2">(</span><span class="token4">'hello'</span><span class="token2">)</span><span class="token2">;</span><span class="token6">//设置内容</span> editor<span class="token2">.</span><span class="token1">hasContents</span><span class="token2">(</span><span class="token2">)</span><span class="token2">;</span><span class="token6">//是否有内容</span> ``` ``` 去掉li中p 进入编辑器的li要套p标签 注释里面内容 去掉p ``` <pre class="calibre16">``` 搜索修改成<span class="token3">false</span>:allowDivTransToP<span class="token2">:</span> <span class="token3">false</span> 再搜索并修改以下: <span class="token6">//编辑器不能为空内容</span> <span class="token5">if</span> <span class="token2">(</span>domUtils<span class="token2">.</span><span class="token1">isEmptyNode</span><span class="token2">(</span>me<span class="token2">.</span>body<span class="token2">)</span><span class="token2">)</span> <span class="token2">{</span> me<span class="token2">.</span>body<span class="token2">.</span>innerHTML <span class="token">=</span> <span class="token4">'<p>'</span> <span class="token">+</span> <span class="token2">(</span>browser<span class="token2">.</span>ie <span class="token">?</span> <span class="token4">''</span> <span class="token2">:</span> <span class="token4">'<br/>'</span><span class="token2">)</span> <span class="token">+</span> <span class="token4">'</p>'</span><span class="token2">;</span> <span class="token2">}</span> 更改为: <span class="token5">if</span> <span class="token2">(</span>domUtils<span class="token2">.</span><span class="token1">isEmptyNode</span><span class="token2">(</span>me<span class="token2">.</span>body<span class="token2">)</span><span class="token2">)</span> <span class="token2">{</span> me<span class="token2">.</span>body<span class="token2">.</span>innerHTML <span class="token">=</span> browser<span class="token2">.</span>ie <span class="token">?</span> <span class="token4">''</span> <span class="token2">:</span> <span class="token4">'<br/>'</span><span class="token2">;</span> <span class="token2">}</span> ``` ```