target 主动联动
只有当前 value为100的时,才会展示 Select组件
主动联动的写法,target加上fulfill,$self可以取出当前字段的值
- target + fulfill
- $self
const phone = {"type": "string","title": "手机号","required": true,"x-validator": "phone","x-decorator": "FormItem","x-component": "Input","x-component-props": {"prefix": "{{icon('PhoneOutlined')}}"},"x-reactions": {// 主动受控,target加 fulfill,只有当前value为123的时候才会展示 Select// 注意,可以修改受控者的哪个value"target": 'Select',"fulfill": {"state": {"visible": "{{$self.value=='100'}}",}},},"name": "phone","x-index": 0}
dependencies 被动联动
被动受控,dependencies 加 fulfill
- dependencies
- $deps
const phone = {"type": "string","title": "手机号","required": true,"x-validator": "phone","x-decorator": "FormItem","x-component": "Input","x-component-props": {"prefix": "{{icon('PhoneOutlined')}}"},"x-reactions": {"dependencies": ["username"],// 组件内部的 state 双花括号是表达式"fulfill": {"state": {"value": "{{$deps[0]}}",}},},"name": "phone","x-index": 0}
x-validator 自定义校验
自定义校验,return 出去的表示校验不通过的提示
const obj = {"x-validator": `{{(value)=> {if(value.length > 10) {return 'Configure up to 10';}if(value.length < 1) {return 'Configure at least one';}}}}`}
Radio 联动

export const schema = {"type": "object","properties": {"rate": {"type": "string | number","title": "打分","x-decorator": "FormItem","x-component": "Radio.Group","enum": [{"children": [],"label": "总分","value": 1},{"children": [],"label": "多维度打分","value": 2}],"x-validator": [],"x-component-props": {"optionType": "button","buttonStyle": "solid"},"x-decorator-props": {},"name": "rate","x-designable-id": "zd6iggh08j7","x-index": 0,"default": 1},"total": {"type": "object","x-validator": [],"name": "total","title": "TOTAL","x-designable-id": "jwkzp4y6rhn","x-index": 1,"x-reactions": {"dependencies": [{"property": "value","type": "string | number","source": "rate","name": "rate"}],"fulfill": {"state": {"visible": "{{$deps.rate === 1}}"}}},"properties": {"user": {"type": "string","title": " 用户","x-decorator": "FormItem","x-component": "Input","x-validator": [],"x-component-props": {},"x-decorator-props": {},"name": "user","x-designable-id": "7awrtm80f44","x-index": 0},"name": {"type": "string","title": "名称","x-decorator": "FormItem","x-component": "Input","x-validator": [],"x-component-props": {},"x-decorator-props": {},"name": "name","x-designable-id": "f3cvhpwhpj6","x-index": 1}}}},"x-designable-id": "wopmqlnr176"}
Select 联动
Segmented

export const schema = {"type": "object","properties": {"price": {"type": "string","title": "费用","x-decorator": "FormItem","x-component": "Segmented","x-validator": [],"x-component-props": {"options": [{ "label": "免费", "value": 0 }, { "label": "收费", "value": 1 }]},"x-decorator-props": {},"name": "price","x-designable-id": "29iv00vj3oy","x-index": 0}},"x-designable-id": "3tdyjr137dx"}
