Variabel 未在方法 VueJs 中定义

我一直在 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


慕后森
浏览 176回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript