Skip to content

代码编辑器


image

介绍

在线编写代码的代码编辑器,它可以直接运行在浏览器中。支持多种语言的语法高亮,以及不同风格的主题,同时还支持实时语法检查,代码折叠,自定义语法提示等功能。

API

Props

参数名描述类型默认值
status默认状态'default'|'hide'|'readonly''default'
title标题string'代码编辑器'
showLabel显示标题booleantrue
value默认值string-
name数据字段string'CODEEDITOR_随机八位字符'
mode编辑器类型'javascript'|'json'|'css'|'html'|'java'|'sql''javascript'
userWorker是否开启语法检测booleantrue
theme主题Theme'eclipse'
fontSize字号string'14'
widthSize-
heightSize-
baseStyle自定义样式string-
customClass类名绑定 , 绑定类的名称string-
uniqueKey唯一标识 , 组件的唯一标识string-
extra补充说明string-
tip气泡提醒string-
validate校验Validate-
loop循环数据, 循环渲染设置Loop-

Events

事件名描述参数
onChange值改变时ctx
params: { value:string }
onFocus获得焦点时ctx
params: FocusEvent
onBlur失去焦点时ctx
params: FocusEvent

Type

js

// 主题
type Theme =
  | "eclipse"
  | "ambiance"
  | "chrome"
  | "clouds"
  | "clouds_midnight"
  | "tomorrow"
  | "tomorrow_night";

// 宽度/高度
type Size = {
  unit: "px" | "%",
  value: string,
};

// 校验
type Validate = {
  required: boolean, // 必填
  requiredMsg: string, // 必填错误提示
  customFunc: boolean, // 自定义函数
  func: string, // 自定义函数
};

// 循环
type Loop = {
  "data": any[],
  "paramName": string,
  "indexName": string,
  "key": string
}

// 循环变量数据参数
type LoopParams = {
  "indexName":string,
  "paramName":string,
  "ref":ComputedRefImpl, // 全部的循环变量数据
  "row":number,
  "rowIndex":number
}[]