1
- ## Vue-Core-Image-Upload
1
+ ## Vue-Core-Image-Upload
2
2
3
- [ Chinese Doc ] ( ./README_CN.md )
3
+ [ ![ npm ] ( https://img.shields.io/npm/v/vue-core-image-upload.svg?maxAge=2592000 )] ( )
4
4
5
- a vue plugin for image upload and crop ( Support π± IE9+)
6
5
7
- if you use vue.js(<=2.0), you should go [ here] ( https://github.com/Vanthink-UED/vue-core-image-upload/tree/v1.x ) .Or select
6
+ a vue plugin for image upload and crop ( Support π± IE10+)
7
+
8
+ [ ζ₯ηζζ‘£] ( http://vanthink-ued.github.io/vue-core-image-upload/index.html#/cn/get-started )
9
+
10
+ [ English Document] ( http://vanthink-ued.github.io/vue-core-image-upload/index.html#/en/home )
11
+
12
+ if you use vue.js(<=2.0), you should go [ here] ( https://github.com/Vanthink-UED/vue-core-image-upload/tree/v1.x ) .Or select
8
13
1.x.x version.
9
14
10
15
<img width =" 360 " src =" ./shots/vue-core-image-upload.png " />
@@ -17,7 +22,19 @@ npm i vue-core-image-upload --save
17
22
```
18
23
19
24
Code Example (ES6)
25
+ ``` html
26
+ <vue-core-image-upload
27
+ :class =" ['btn', 'btn-primary']"
28
+ :crop =" false"
29
+ @imageuploaded =" imageuploaded"
30
+ :data =" data"
31
+ :max-file-size =" 5242880"
32
+ url =" your server url" >
33
+ </vue-core-image-upload >
34
+ ```
20
35
``` js
36
+
37
+
21
38
import VueCoreImageUpload from ' vue-core-image-upload' ;
22
39
23
40
new Vue ({
@@ -38,104 +55,114 @@ new Vue({
38
55
});
39
56
```
40
57
41
- Use CDN Script(ES5)
42
- ``` js
43
-
44
- // include the script ./node_modules/vue-core-image-upload/index.js
45
- < script src= " http://s1.vued.vanthink.cn/3e3f5b16269d/vue-core-image-upload.js" >< / script>
46
- ...
47
- < script>
48
- var MyComponent = Vue .extend (VueCoreImageUpload);
49
- new Vue ({
50
- el: ' #app' ,
51
- components: {
52
- ' vue-core-image-upload' : MyComponent
53
- },
54
- data: {
55
- src: ' http://img1.vued.vanthink.cn/vued0a233185b6027244f9d43e653227439a.png' ,
56
- },
57
- methods: {
58
- imageuploaded : function (res ) {
59
- if (res .errcode == 0 ) {
60
- this .src = ' http://img1.vued.vanthink.cn/vued751d13a9cb5376b89cb6719e86f591f3.png' ;
61
- }
62
- }
63
-
64
- }
65
- < / script>
66
- ` ` `
67
-
68
- ` ` ` html
69
- < vue- core- image- upload
70
- v- bind: class = " ['pure-button','pure-button-primary','js-btn-crop']"
71
- v- bind: crop= " false"
72
- url= " ./crop.php"
73
- extensions= " png,gif,jpeg,jpg" >
74
- < / vue- core- image- upload>
75
- ` ` `
76
-
77
58
[ Demo] (http://vanthink-ued.github.io/vue-core-image-upload/upload.html )
78
59
79
- ### Options
80
-
81
- | Props | Type | Example | Description |
82
- | ------------- |:----------| ---------|--------------|
83
- | url | String | '/crop.php' | your server url |
84
- | text | String | 'Upload Image' | the text you want to show |
85
- | inputOfFile | String | 'file' | upload file form name |
86
- | extensions | String | 'png,jpg,gif' | limit the file type |
87
- | crop | Boolean | true | if need crop image |
88
- | cropRatio | String | '1:1' | limit the cropped image shape|
89
- | cropBtn | Object | {ok:'Save','cancel':'Give Up'} | the text of crop button|
90
- | maxFileSize | Number | 10485760(10M) | limit the file size|
91
- | maxWidth | Number | 150 | limit the width of your image you cropped|
92
- | maxheight | Number | 150 | limit the height of your image you cropped|
93
- | inputAccept | string | 'image/*' / 'image/jpg,image/jpeg,image/png' | the image file of accept type |
94
- | isXhr | Boolean | true | cancel default xhr uploading
95
- | headers | Object | {auth: xxxxx} | the http header to send server
96
- | data | Object | {id: xxxxx} | the http post data to send server
97
-
98
- ### $dispatch, events
99
-
100
- ` ` ` js
101
- // finish image uload
102
- imageuploaded (res ) {
103
- if (res .errcode == 0 ) {
104
- this .src = ' http://img1.vued.vanthink.cn/vued751d13a9cb5376b89cb6719e86f591f3.png' ;
105
-
106
- }
107
- }
108
- // return file object
109
- imagechanged (res ) {
110
- console .log (res .name )
111
- }
112
-
113
-
114
- // uploading image
115
- imageuploading (res ) {
116
- console .info (' uploading' );
117
- }
118
-
119
- // handle some error like ajax not working
120
- errorhandle (err ) {
121
- console .error (err);
122
- }
123
- ` ` `
124
-
125
- ### Server Crop Arguments
126
-
127
- If you crop a image , your crop will send a request to your server with some crop arguments;
128
-
129
-
130
- <img src="./shots/vuedba0ed377b88fc84d51026310efcb255b.png" />
131
-
60
+ ### Props
61
+ <table class =" m-table bordered " >
62
+ <thead >
63
+ <tr>
64
+ <th>Props</th>
65
+ <th align="left">Data Type</th>
66
+ <th>Example</th>
67
+ <th>Details</th>
68
+ </tr>
69
+ </thead >
70
+ <tbody >
71
+ <tr>
72
+ <td>url</td>
73
+ <td align="left">String</td>
74
+ <td>'/crop.php'</td>
75
+ <td>Your server api</td>
76
+ </tr>
77
+ <tr>
78
+ <td>text</td>
79
+ <td align="left">String</td>
80
+ <td>'Upload Image'</td>
81
+ <td>The text of your uploading button</td>
82
+ </tr>
83
+ <tr>
84
+ <td>inputOfFile</td>
85
+ <td align="left">String </td>
86
+ <td> 'file'</td>
87
+ <td>Yout input[file] name</td>
88
+ </tr>
89
+ <tr>
90
+ <td>extensions</td>
91
+ <td align="left">String</td>
92
+ <td>'png,jpg,gif'</td>
93
+ <td>Limit the image type</td>
94
+ </tr>
95
+ <tr>
96
+ <td>crop</td>
97
+ <td align="left">Boolean</td>
98
+ <td>'server'</td>
99
+ <td>Crop image option</td>
100
+ </tr>
101
+ <tr>
102
+ <td>cropRatio</td>
103
+ <td align="left">String</td>
104
+ <td>'1:1'</td>
105
+ <td>The cropped image shape</td>
106
+ </tr>
107
+ <tr>
108
+ <td>cropBtn</td>
109
+ <td align="left">Object</td>
110
+ <td>{ok:'Save','cancel':'Give Up'}</td>
111
+ <td>The Text of cropping button text</td>
112
+ </tr>
113
+ <tr>
114
+ <td>maxFileSize</td>
115
+ <td align="left">Number</td>
116
+ <td>10485760(10M)</td>
117
+ <td>Limit the size of the file</td>
118
+ </tr>
119
+ <tr>
120
+ <td>maxWidth</td>
121
+ <td align="left">Number</td>
122
+ <td>150</td>
123
+ <td>The maximum width of cropped image </td>
124
+ </tr>
125
+ <tr>
126
+ <td>maxheight</td>
127
+ <td align="left">Number</td>
128
+ <td>150</td>
129
+ <td>ιεΆεΎηηζε€§ι«εΊ¦</td>
130
+ </tr>
131
+ <tr>
132
+ <td>inputAccept</td>
133
+ <td align="left">string</td>
134
+ <td>'image/*' / 'image/jpg,image/jpeg,image/png'</td>
135
+ <td>the input[file] accept</td>
136
+ </tr>
137
+ <tr>
138
+ <td>compress</td>
139
+ <td align="left">Number</td>
140
+ <td>50</td>
141
+ <td>Set the quality of compressed image</td>
142
+ </tr>
143
+ <tr>
144
+ <td>isXhr</td>
145
+ <td align="left">Boolean</td>
146
+ <td>true</td>
147
+ <td>IF cancel ajax uploading</td>
148
+ </tr>
149
+ <tr>
150
+ <td>headers</td>
151
+ <td align="left">Object</td>
152
+ <td>{auth: xxxxx}</td>
153
+ <td>Set customed header when ajax uploading</td>
154
+ </tr>
155
+ <tr>
156
+ <td>data</td>
157
+ <td align="left">Object</td>
158
+ <td>{auth: xxxxx}</td>
159
+ <td>Set customed data when ajax posting server</td>
160
+ </tr>
161
+ </tbody >
162
+ </table >
163
+
164
+ ### Contributions
165
+
166
+ Your contributions and suggestions are welcome ππππππ.
132
167
133
- + ` toCropImgX` : the distance of cropbox to the image left;
134
- + ` toCropImgY` : the distance of cropbox to the image top
135
- + ` toCropImgW` : the width of cropbox
136
- + ` toCropImgH` : the height of cropbox
137
- + ` maxWidth` : the maxium width of your target image
138
- + ` maxHeight` : the maxium height of your target image
139
- If you want to change the crop window style , you should write your own css files.
140
168
141
- ### MIT Liscense
0 commit comments