Created
June 5, 2019 18:57
-
-
Save chrisdel101/1b07b4f7a527bf8ceb1040331d3d8b5c to your computer and use it in GitHub Desktop.
Example of using computed
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
// When input it blank, this returns the error | |
// INPUT | |
<fg-input | |
v-model="editCustomer.firstName" | |
placeholder="First Name" | |
label="First Name" | |
name="firstName" | |
:error="handleErrors" | |
></fg-input> | |
// computed | |
handleErrors(){ | |
if(!this.editCustomer.firstName){ | |
return this.errorMessages.blankError | |
} | |
}, | |
// errors in data | |
errorMessages: { | |
blankError: 'Input cannot be blank', | |
nonNumericError: 'Input must be numeric', | |
invalidEmail: 'Invalid email address format' | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment