Last active
July 26, 2019 17:40
-
-
Save ramon-src/29043eb539a1db4085ff62889561d9e3 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
const app = new Vue({ | |
el: '#app', | |
data: { | |
errors: [], | |
name: null, | |
usuario: null, | |
senha: null, | |
age: null, | |
movie: null | |
}, | |
methods: { | |
checkForm: function (e) { | |
if (this.name && this.usuario && this.senha) { | |
return true; | |
} | |
this.errors = []; | |
if (!this.name) { | |
this.errors.push('O nome é obrigatório.'); | |
} | |
if (!this.usuario) { | |
this.errors.push('O nome é obrigatório.'); | |
} | |
if (!this.senha) { | |
this.errors.push('A senha é obrigatória.'); | |
} | |
e.preventDefault(); | |
this.formSubmit(); | |
}, | |
formSubmit() { | |
console.info('form'); | |
let currentObj = this; | |
this.axios.post('http://localhost/formulario/action/actions.php', { | |
name: this.name, | |
idade: this.age, | |
usuaro: this.usuario, | |
senha: this.senha | |
}).then(function (response) { | |
currentObj.output = response.data; | |
}).catch(function (error) { | |
currentObj.output = error; | |
}); | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment