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

bug fixes

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