UEditor編輯器使用示例

libingql發表於2016-09-30

1. UEditor下載

  UEditor是由百度web前端研發部開發所見即所得富文字web編輯器,具有輕量,可定製,注重使用者體驗等特點,開源基於MIT協議,允許自由使用和修改程式碼。

  下載連結:http://ueditor.baidu.com/

2. 初始化編輯器

2.1 script初始化

  HTML程式碼:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>UEditor示例</title>
    <script type="text/javascript" src="/Plugins/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" src="/Plugins/ueditor/ueditor.all.js"></script>
</head>
<body>
    <script id="container" type="text/plain">
    </script>

    <script type="text/javascript">
        var ue = UE.getEditor("container");
    </script>
</body>
</html>

  效果圖:

2.2 TextArea初始化

   HTML程式碼:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>UEditor示例</title>
    <script src="/Plugins/ueditor/ueditor.config.js"></script>
    <script src="/Plugins/ueditor/ueditor.all.js"></script>

</head>
<body>
    <textarea cols="20" id="Remark" name="Remark" rows="2"></textarea>

    <script type="text/javascript">
        var editor = new baidu.editor.ui.Editor();
        editor.render("Remark");
    </script>
</body>
</html>

 

相關文章