Created
October 2, 2020 13:46
-
-
Save Julien1138/5e195aa8cee4a7f7bf4a00d6abe54ba7 to your computer and use it in GitHub Desktop.
This file contains 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 :field="field"></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