Skip to content

Instantly share code, notes, and snippets.

@chrisdel101
Created June 5, 2019 18:57
Show Gist options
  • Save chrisdel101/1b07b4f7a527bf8ceb1040331d3d8b5c to your computer and use it in GitHub Desktop.
Save chrisdel101/1b07b4f7a527bf8ceb1040331d3d8b5c to your computer and use it in GitHub Desktop.
Example of using computed
// 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