博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Simditor 富文本编辑器基本使用
阅读量:7072 次
发布时间:2019-06-28

本文共 1142 字,大约阅读时间需要 3 分钟。

官方文档:

Simditor是一个非常不错的web轻量级编辑器,设置简单,功能较为齐全,重点是样式相对较为好看 ^_^

引入文件

  • css
  • js

基本实例化

  • html
  • js
var editor = new Simditor({    toolbar: [        'title', 'bold', 'italic', 'underline', 'strikethrough', 'fontScale',        'color', '|', 'ol', 'ul', 'blockquote', 'code', 'table', '|', 'link',        'image', 'hr', '|', 'alignment'    ],    textarea: '#editor',    placeholder: '写点什么...',    defaultImage: '/static/home/images/logo.png',    imageButton: ['upload'],    upload: {        url: '/article/upload',        params: {_token: token},        fileKey: 'file',        leaveConfirm: '正在上传文件..',        connectionCount: 3    }});

常用方法

  • 设置值: editor.getValue()
  • 获取值: editor.setValue(value)
  • 获取焦点: editor.focus()
  • 失去焦点: editor.blur()

常用参数

  • 编辑器实例化textarea节点,可以是jqueyr选择器也可以是jquery对象: textarea
  • 图片上传方式按钮: imageButton
  • 上传图片相关参数(object): upload
  • 上传地址: upload.url
  • 上传附加参数(object): upload.params
  • 上传的name值: fileKey: 'file' 在服务端接收的键(以PHP为例): $_FILE['file']

注意点

  • 上传文件时,必须返回一个指定格式的 json, 不然报错
echo json_encode([    'success' => true,    'msg' => '图片上传错误信息',    'file_path' => '/upload/2018_10_11/1.jpg']);

转载于:https://www.cnblogs.com/liaohui5/p/10581599.html

你可能感兴趣的文章
cacti的基本应用
查看>>
MYSQL错误代码集
查看>>
Centos7 命令总结
查看>>
lufylegend HTML5开源框架基本操作
查看>>
startActivityForResult备忘
查看>>
android webrtc使用opensl es
查看>>
spring mvc restful + json 测试代码(一)
查看>>
在控制台程序中使用MFC类
查看>>
用enum类型数据解决switch case选择字符串的问题
查看>>
Exception happened during processing of request
查看>>
微服务间的通信如何选择
查看>>
android中的智能指针
查看>>
PHP获取今天、明天、一个月后、一年后等等时间函数
查看>>
wampServer配置局域网文件共享
查看>>
SpringBoot基础教程2-1-2 Controller规范及响应规范
查看>>
在两个ASP.NET页面之间传递值(转)
查看>>
linux安装软件备忘
查看>>
Springboot 笔记
查看>>
自己动手实现RPC服务调用框架
查看>>
AngularJs学习笔记--bootstrap
查看>>