Skip to content

Commit

Permalink
fix: form prop rules不生效 (#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
yolofit authored Dec 31, 2020
1 parent a129d3f commit 4d518ce
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
41 changes: 41 additions & 0 deletions docs/rules-plus.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
```vue
<template>
<el-form-renderer
label-width="100px"
:content="content"
ref="form"
:rules="rules"
>
</el-form-renderer>
</template>
<script>
export default {
data() {
const rules = [
{ required: true, message: '请输入活动名称', trigger: 'change' },
{ min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'change' }
];
return {
rules: {
name: [...rules],
},
content: [
{
type: "input",
id: "name",
label: "name",
},
{
type: "input",
id: "desc",
label: "desc",
rules: [...rules],
},
],
};
},
}
</script>
```
2 changes: 1 addition & 1 deletion src/components/render-form-item.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
v-if="_show"
:prop="prop"
:label="typeof data.label === 'string' ? data.label : ''"
:rules="!readonly && Array.isArray(data.rules) ? data.rules : []"
:rules="!readonly && Array.isArray(data.rules) ? data.rules : undefined"
v-bind="data.attrs"
class="render-form-item"
>
Expand Down

0 comments on commit 4d518ce

Please sign in to comment.