Created
October 1, 2020 13:51
-
-
Save Julien1138/7c090cb7207333367d2c1033cd94650d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <template> | |
| <div class="form-element"> | |
| <div>{{ field.title }}</div> | |
| <slot :value="field.value"></slot> | |
| <div v-if="empty" class="empty">Must not be empty</div> | |
| </div> | |
| </template> | |
| <script> | |
| export default { | |
| props: { | |
| field: { | |
| type: Object, | |
| default: () => {} | |
| }, | |
| }, | |
| computed: { | |
| empty() { | |
| if (this.field.value) { | |
| return this.field.value.length === 0 | |
| } | |
| return true | |
| } | |
| }, | |
| } | |
| </script> | |
| <style scoped> | |
| .form-element { | |
| margin-bottom: 1rem | |
| } | |
| .empty { | |
| color: red | |
| } | |
| </style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment