Laravel 如何从Laravue中的其他文件请求响应获取响应

Laravel 如何从Laravue中的其他文件请求响应获取响应,laravel,api,vue.js,request,http-post,Laravel,Api,Vue.js,Request,Http Post,我正在尝试从File2.vue获取响应,并将其传递回File1.vue。我正在使用VueJS v1.0.28,如何从其他文件请求响应获取响应 File1.vue File2.updateNotice(this,{'id':id}).then((response) => { console.log("response from File2 :",response) }); updateNotice(context,params) { le

我正在尝试从File2.vue获取响应,并将其传递回File1.vue。我正在使用VueJS v1.0.28,如何从其他文件请求响应获取响应

File1.vue

   File2.updateNotice(this,{'id':id}).then((response) => {
      console.log("response from File2  :",response)
   }); 
updateNotice(context,params) {
            let url = staff_service.STAFF_NOTICES_READ_RESOURCE;
            Vue.http.post(
                url,
                params
            ).then(response => {
                return response;
            }) 
}
   File2.updateNotice(this,{'id':id}).then((response) => {
      console.log("response from File2  :",response)
   }); 
updateNotice(context,params) {
            let url = staff_service.STAFF_NOTICES_READ_RESOURCE;
            return Vue.http.post(
                url,
                params
            ).then(response => {
                return response;
            }) 
}
File2.vue

   File2.updateNotice(this,{'id':id}).then((response) => {
      console.log("response from File2  :",response)
   }); 
updateNotice(context,params) {
            let url = staff_service.STAFF_NOTICES_READ_RESOURCE;
            Vue.http.post(
                url,
                params
            ).then(response => {
                return response;
            }) 
}
   File2.updateNotice(this,{'id':id}).then((response) => {
      console.log("response from File2  :",response)
   }); 
updateNotice(context,params) {
            let url = staff_service.STAFF_NOTICES_READ_RESOURCE;
            return Vue.http.post(
                url,
                params
            ).then(response => {
                return response;
            }) 
}
来自文件1的错误响应:

Cannot read property 'then' of undefined
这一点现在已经解决了,补充道

返回

以前

Vue.http.post(

File2.vue中

   File2.updateNotice(this,{'id':id}).then((response) => {
      console.log("response from File2  :",response)
   }); 
updateNotice(context,params) {
            let url = staff_service.STAFF_NOTICES_READ_RESOURCE;
            Vue.http.post(
                url,
                params
            ).then(response => {
                return response;
            }) 
}
   File2.updateNotice(this,{'id':id}).then((response) => {
      console.log("response from File2  :",response)
   }); 
updateNotice(context,params) {
            let url = staff_service.STAFF_NOTICES_READ_RESOURCE;
            return Vue.http.post(
                url,
                params
            ).then(response => {
                return response;
            }) 
}
File1.vue

   File2.updateNotice(this,{'id':id}).then((response) => {
      console.log("response from File2  :",response)
   }); 
updateNotice(context,params) {
            let url = staff_service.STAFF_NOTICES_READ_RESOURCE;
            Vue.http.post(
                url,
                params
            ).then(response => {
                return response;
            }) 
}
   File2.updateNotice(this,{'id':id}).then((response) => {
      console.log("response from File2  :",response)
   }); 
updateNotice(context,params) {
            let url = staff_service.STAFF_NOTICES_READ_RESOURCE;
            return Vue.http.post(
                url,
                params
            ).then(response => {
                return response;
            }) 
}
File2.vue

   File2.updateNotice(this,{'id':id}).then((response) => {
      console.log("response from File2  :",response)
   }); 
updateNotice(context,params) {
            let url = staff_service.STAFF_NOTICES_READ_RESOURCE;
            Vue.http.post(
                url,
                params
            ).then(response => {
                return response;
            }) 
}
   File2.updateNotice(this,{'id':id}).then((response) => {
      console.log("response from File2  :",response)
   }); 
updateNotice(context,params) {
            let url = staff_service.STAFF_NOTICES_READ_RESOURCE;
            return Vue.http.post(
                url,
                params
            ).then(response => {
                return response;
            }) 
}

您的问题是什么?请澄清。您已经安慰了您的回答。我想从File2.vue获得响应并传递回File1.vue。您可以使用vuex,将响应传递给state。在
File1.vue
中检查状态更改,并在
file.vue
中获取值。您需要在
vue.http.post
之前返回到r将承诺返回给调用者-否则,您不会从
updateNotice
返回任何内容,因此
然后
是undefined@steve16351哦,我的!#$%&(!!!!!我的错,谢谢!我现在可以得到回复,但忘记放一些回执。节省了我很多时间。