定义 自定义组件配置
系统提供的插件类型有:’string‘, ‘number’,’boolean’, ‘select’,’color’, ‘display’, ‘box-editor’,’array’,’object’,
系统插件使用 查看:https://github.com/ascoders/gaea-editor
props配置
props 定义class Props {editSetting = { // editSetting 为 插件提供 必须的名称key: 'gaea-page-header', // 关键字段必须,已gaea- 开头name: '页头', // 组件名字 在组件栏展示editors: [ // 该组件使用 插件的配置"盒子模型", // 配置底下连续 的 json 说明{type: 'box-editor' // 盒模型 系统提供 的插件,},"元素配置",,{field: 'title', // 字段名 会传到组件的props中text: '标题', // 文本type: 'string' // 使用的插件名},{field: 'subTitle',text: '子标题',type: 'string'},"选项设置",// 数组对象配置{field: 'options',text: 'Options',type: 'array',data: [{field: 'value',type: 'string',text: 'Value'},{field: 'text',type: 'string',text: 'Text'},{field: 'disabled',type: 'boolean',text: 'Disabled'}]},{field: 'disabled',text: 'Disabled',type: 'boolean'},]}}
组件中使用props
import { PageHeader, Icon } from 'antd';import React, { Component } from 'react';import { Props, State } from './type'export default class AntBackTop extends Component {static defaultProps = new Props(); // 必须示例化 并取名为defaultProps,gaea-editor会在初始化化的时候读取defaultPropsstate = new State();render() {const { props } = thisreturn (// this.props.styles 如果有使用盒模型的插件<PageHeader style={this.props.styles} title={props.title} subTitle={props.subTitle} />)}}
