# 基础控件

controls 可在外部ui组件、行为组件、规则组件中使用

以下公共参数在所有controls中均可使用

config:{
  jumpStatus: {
    text: '成功后是否跳转',
    type: 'RadioButton',
    options: [
      {
        text: '是',
        value: 1
      },
      {
        text: '否',
        value: 0
      }
    ],
    require: true // require 为true时,validate默认添加,仅验证内容是否为空 
  },
  url: {
    text:  '链接',
    type: 'NormalText',
    msg: 'https的链接',
    require: true,
    validate(value) {
      // validate 方法 返回 当前值
      if (!value) {
        return {
          stat: false,
          msg: '请输入链接'
        };
      } 
      if (/^https?:\/\/.*/.test(value)) {
        return {
          stat: true,
          msg: ''
        };
      } else {
        return {
          stat: false,
          msg: '请输入正确的链接地址'
        };
      }
    },
    when(widget, project) {
      // when 返回两个参数,widget 为当前组件,project 为当前项目
      return widget.data.jumpStatus == 1
    }
  }
}
  • 公共参数

所有control均有的参数

参数 说明 类型 可选值 默认值 是否必填
text 名称 string * -
type 名称 string 下面的controls 下面的controls
msg 名称说明 string * -
require 是否必填 boolean ture/false false
validate 校验函数,reuqire为true时默认添加 function function(value) -
when 显示条件 function function(widget, project) *
useData 是否使用数据源(仅限ui和行为组件中使用) boolean true/false false
readOnly 控件是否只可读(富文本,颜色选择,选项列表暂不支持) boolean true/false false
  • 使用数据的用法
config:{
  name: {
    text:  '标题',
    type: 'NormalText',
    useData: true
  }
},
data: {
  name: ''
}
...
onMount() {
  const { useDataValue, variableMap, page, project } = ctx
  const getDataValue = (val) => useDataValue(val, variableMap, page, project)
  getDataValue(this.data.name)
}

xes-save