Created
October 2, 2020 13:29
-
-
Save Julien1138/2c5d76ae55ae9e88ac8bda28973b9242 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 :value="field.value" :update="update"></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 | |
} | |
}, | |
methods: { | |
update(event) { | |
this.field.value = event.target.value | |
} | |
} | |
} | |
</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