简体   繁体   English

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

[英]How to get response from other file request response in Laravue

I'm trying to get the response from File2.vue and pass back to File1.vue.我正在尝试从 File2.vue 获取响应并传回 File1.vue。 I'm using VueJS v1.0.28, How to get response from other file request response?我正在使用 VueJS v1.0.28,如何从其他文件请求响应中获取响应?

File1.vue文件1.vue

   File2.updateNotice(this,{'id':id}).then((response) => {
      console.log("response from File2  :",response)
   }); 

File2.vue文件2.vue

updateNotice(context,params) {
            let url = staff_service.STAFF_NOTICES_READ_RESOURCE;
            Vue.http.post(
                url,
                params
            ).then(response => {
                return response;
            }) 
}

Error response from File1:来自 File1 的错误响应:

Cannot read property 'then' of undefined

This is now solved, added a现在解决了,添加了一个

return返回

before

Vue.http.post( Vue.http.post(

in File2.vueFile2.vue

File1.vue文件1.vue

   File2.updateNotice(this,{'id':id}).then((response) => {
      console.log("response from File2  :",response)
   }); 

File2.vue文件2.vue

updateNotice(context,params) {
            let url = staff_service.STAFF_NOTICES_READ_RESOURCE;
            return Vue.http.post(
                url,
                params
            ).then(response => {
                return response;
            }) 
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM