复制成功!
<template>
<div>
<form-create :rule="rule" v-model:api="fApi" :option="options"/>
</div>
</template>
<script>
export default {
data() {
return {
fApi: {},
options: {
onSubmit: (formData) => {
alert(JSON.stringify(formData))
}
},
rule: [
{
type: 'input',
field: 'field1',
title: 'field1',
info: 'info......',
value: 'aaa',
class: 'my-class',
props: {
disabled: false,
},
prefix: {
type: 'div',
style: 'color:red',
children: ['红色的前缀']
},
suffix: '简单的后缀',
children: [
{
type: 'button',
name: 'button',
slot: 'suffix',
on: {
click: () => {
const rule = this.fApi.getRule('field1');
rule.props.disabled = !rule.props.disabled;
this.fApi.getRule('button').children = rule.props.disabled ? ['恢复'] : ['禁用'];
}
},
children: ['禁用']
}
]
},
{
children: ['自定义Tag组件'],
native: false,
title: "tag",
type: "elTag"
}
]
}
}
}
</script>