若依框架 富文本编辑器

若依框架 富文本编辑器

//引入
<head>
    <meta charset="UTF-8">
    <title>without bootstrap</title>
    <script src="../../../static/js/jquery-3.4.1.slim.min.js" th:src="@{/js/jquery-3.4.1.slim.min.js}"></script>
    <link href="../../../static/css/summernote-lite.min.css" th:href="@{/css/summernote-lite.min.css}" rel="stylesheet" />
    <link href="../../../static/css/font/summernote.woff2" th:href="@{/css/font/summernote.woff2}" rel="stylesheet" />
    <link href="../../../static/css/font/summernote.woff" th:href="@{/css/font/summernote.woff}" rel="stylesheet" />
    <script src="../../../static/js/summernote-lite.min.js" th:src="@{/js/summernote-lite.min.js}"></script>
    <script src="../../../static/js/summernote-zh-CN.js" th:src="@{/js/summernote-zh-CN.js}"></script>
</head>
//定义富文本
<div id="summernote"></div>

<script>
//初始化
    $('#summernote').summernote({
        lang : 'zh-CN',// 语言
        placeholder: 'Hello stand alone ui',
        tabsize: 2,
        height: 120,//高度
        toolbar: [
            ['style', ['style']],
            ['font', ['bold', 'underline', 'clear']],
            ['color', ['color']],
            ['para', ['ul', 'ol', 'paragraph']],
            ['table', ['table']],
            ['insert', ['link', 'picture', 'video']],
            ['view', ['fullscreen', 'codeview', 'help']]
        ]
    });
    
    
//保存富文本内容
   //取值
       var markupStr = $('#summernote').summernote('code')

       //保存非图片类
       var url = "/suumo/house/summernote";
       $.ajax({
           url : url,
           async: false,
           type:"post",
           data : {"ftext":markupStr},
           success: function (data) {
               console.log("保存成功")

           }
       });


//编辑页面有内容时初始化
    var inputext;
    $(function() {
        //获取富文本的值
         inputext = $("#inputtext").val();
        //赋值
        $('#summernote').summernote("code",inputext);
    })
</script>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值