1 回答

TA貢獻1829條經驗 獲得超4個贊
在模板(html文件)將要使用Ueditor的textarea,設定一個id值,以便在Ueditor中使用
在ThinkPHP的模板(html文件)中引入Ueditor
<script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.all.min.js"></script>
<!--建議手動加在語言,避免在ie下有時因為加載語言失敗導致編輯器加載失敗-->
<!--這里加載的語言文件會覆蓋你在配置項目里添加的語言類型,比如你在配置項目里配置的是英文,這里加載的中文,那最后就是中文-->
<script type="text/javascript" src="__PUBLIC__/ueditor/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">
UE.getEditor('content',{ //content為要編輯的textarea的id
initialFrameWidth: 1100, //初始化寬度
initialFrameHeight: 500, //初始化高度
});
</script>
在ThinkPHP的控制器中接收數據,接收數據還有原來一樣,使用create方法或者I。
數據存儲在數據庫中是一個字符串
將數據取出并顯示在html文件中,記住這一步要使用php的htmlspecialchars_decode函數,將HTML 實體轉換為字符,格式如下:
{:htmlspecialchars_decode($row['ar_content'])}
然輸入
<input type="button" id="btn"/>
<script type="text/javascript">
document.getElementById("btn").onclick=function(){
if(document.getElementById("fileID").value==""){
alert("查找附件");
}
}
</script>
做完上面步驟,就大功告成了,在我們剛才添加的頁面測試一下Ueditor。
- 1 回答
- 0 關注
- 844 瀏覽
添加回答
舉報