我一直在 VueJs 方法中定义一个对象,并希望将该对象用于 axios,如下所示:
data() {
return {
name : '',
password: '',
email: ''
}
},
methods: {
submit() {
sendData = {
name: this.name,
password: this.password,
email: this.email
}
axios.post('http://localhost:8000/api/users', sendData)
.then(response => {
console.log(response);
})
.catch(error => {
console.log(error)
})
}
}
输出是 ReferenceError: sendData is not defined
相关分类