我正在尝试从File2.vue获得响应并将其传递回File1.vue。我正在使用VueJS v1.0.28,如何从其他文件请求响应中获取响应?
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;
})
}
来自File1的错误响应:
Cannot read property 'then' of undefined
答案 0 :(得分:0)
现在解决了,添加了一个
返回
之前
File2.vue 中的Vue.http.post(
File1.vue 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;
return Vue.http.post(
url,
params
).then(response => {
return response;
})
}