Skip to content

Commit 50bf084

Browse files
committed
flx oss
1 parent 892e25b commit 50bf084

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "vue-image-crop-upload",
3-
"version": "2.5.0",
2+
"name": "rui-vue-image-crop-upload",
3+
"version": "2.5.12",
44
"description": "a vue plgin for image upload and crop(vue图片剪裁上传插件)",
55
"main": "upload-2.vue",
66
"scripts": {
@@ -71,5 +71,8 @@
7171
"vue-style-loader": "^1.0.0",
7272
"webpack": "^1.13.1",
7373
"webpack-stream": "^3.2.0"
74+
},
75+
"directories": {
76+
"example": "example"
7477
}
7578
}

upload-2.vue

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,11 @@ export default {
199199
},
200200
beforeUpload: {
201201
type: Function,
202-
'default': () => null
202+
'default': () => {}
203+
},
204+
cropUploadSuccess: {
205+
type: Function,
206+
'default': () => {}
203207
}
204208
},
205209
data() {
@@ -800,7 +804,7 @@ export default {
800804
},
801805
// 上传图片
802806
async upload() {
803-
await beforeUpload()
807+
await this.beforeUpload(this.createImgUrl, this.field, this.ki)
804808
805809
let that = this,
806810
{
@@ -817,7 +821,6 @@ export default {
817821
method
818822
} = this,
819823
fmData = new FormData();
820-
fmData.append(field, data2blob(createImgUrl, mime), field + '.' + imgFormat);
821824
822825
// 添加其他参数
823826
if (typeof params == 'object' && params) {
@@ -826,6 +829,8 @@ export default {
826829
})
827830
}
828831
832+
fmData.append(field, data2blob(createImgUrl, mime), field + '.' + imgFormat);
833+
829834
// 监听进度回调
830835
const uploadProgress = function(event) {
831836
if (event.lengthComputable) {
@@ -864,7 +869,7 @@ export default {
864869
function(resData) {
865870
if (that.value) {
866871
that.loading = 2;
867-
that.$emit('crop-upload-success', resData, field, ki);
872+
that.$emit('crop-upload-success', resData, field, ki, that.reset);
868873
}
869874
},
870875
// 上传失败
@@ -873,7 +878,7 @@ export default {
873878
that.loading = 3;
874879
that.hasError = true;
875880
that.errorMsg = lang.fail;
876-
that.$emit('crop-upload-fail', sts, field, ki);
881+
that.$emit('crop-upload-fail', sts, field, ki, that.reset);
877882
}
878883
}
879884
);

0 commit comments

Comments
 (0)