简体   繁体   中英

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. I'm using VueJS v1.0.28, How to get response from other file request response?

File1.vue

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

File2.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:

Cannot read property 'then' of undefined

This is now solved, added a

return

before

Vue.http.post(

in File2.vue

File1.vue

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

File2.vue

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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