mosayeb
4 سال پیش توسط mosayeb مطرح شد
0 پاسخ

خالی بودن object هنگام درخواست خارجی در vuejs

با سلام
بنده با استفاده از vuejs یک درخواست خارجی دارم میفرستم اما وقتی با تلفن همراه لود میکنم مقدار خالیه در صورتی که در pc این مشکل وجود نداره.

var app = new Vue({
            el : "#app",
            data : {
                teachers : {},
                test : {fname : "mosayeb"},
                courses : {},
                teacher_id : null,
                course_id : null,
                point : 4,
                description : ''
            },
            methods : {
            async getTeachers(){
            let teachers  =  await  axios.get('http://example.com/api/v1/getTeachers');
            this.teachers = teachers.data.data;

                      console.log(this.teachers);

                /*this.teacher_id = this.teachers[0].id;
                this.getCourse(this.teacher_id);
                this.course_id = this.courses[0].id;*/

            },
                changeTeacher(event){
                this.getCourse(event.target.value);
                this.teacher_id = event.target.value;

                },
                 getCourse(id = 1){
                 axios.get(`http://example.com/api/v1/getCourses?teacher_id=${id}`).then(function (res) {
                     this.courses = res.data.data;

                 });
                },
                changeCourse(event){
                    this.course_id = event.target.value;

                },
                formSubmit(){
                let text = 'نظرت ثبت شد.از این که ما رو همراهی کردی ممنونم';

                        axios.post(`http://example.com/api/v1/pull`).then(function (res) {
                     res.data.data
                });
                console.log(this.teachers);
                    Swal.fire({
                        title: 'حله!',
                        text: text,
                        icon: 'success',
                        confirmButtonText: 'خیلی خب'
                    })
                }
            },
            created (){

                this.getTeachers();

            }
        });

@hesammousavi @juza66 @ali.bayat @elyasbeshkani


ثبت پرسش جدید

به همدیگه کمک کنیم

به mosayeb کمک کنید تا مشکل خودش را حل کند؛ این‌طور می‌توانیم با هم پیشرفت کنیم.

برای ارسال پاسخ لازم است وارد شده یا ثبت‌نام کنید

ورود یا ثبت‌نام