提交 fe9acf9f authored 作者: 王鹏飞's avatar 王鹏飞

bug fixes

上级 e10989ee
{
"name": "@ezijing/vue-form",
"version": "2.0.4",
"version": "2.0.5",
"private": false,
"description": "基于Vue Element-UI的表单",
"scripts": {
......
......@@ -121,7 +121,16 @@ export default {
},
// 获取
getData() {
let { action: url, method = 'get', headers = {}, params = {}, data = {}, beforeRequest, callback } = this.get
let {
action: url,
method = 'get',
headers = {},
params = {},
data = {},
beforeRequest,
callback,
errorCallback
} = this.get
if (beforeRequest) {
data = beforeRequest(data)
}
......@@ -143,7 +152,13 @@ export default {
}
this.model = res
})
.catch(error => this.$emit('error', error))
.catch(error => {
if (errorCallback) {
errorCallback.call(this, error)
} else {
this.$emit('error', error)
}
})
},
// 更新
async updateData(formData) {
......@@ -156,12 +171,15 @@ export default {
await httpRequest
.post(action, formData, { headers })
.then(res => {
callback && callback(res)
this.$emit('success', res)
if (callback) {
callback.call(this, res)
} else {
this.$emit('success', res)
}
})
.catch(error => {
if (errorCallback) {
errorCallback()
errorCallback.call(this, error)
} else {
this.$emit('error', error)
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论