|
8 | 8 | ## Install |
9 | 9 |
|
10 | 10 | ``` bash |
11 | | - npm install vue-upload-component --save |
| 11 | + npm install vue-upload-component@next --save |
12 | 12 | ``` |
| 13 | + |
13 | 14 | ### CommonJS |
14 | 15 | ```js |
15 | 16 | var FileUpload = require('vue-upload-component'); |
@@ -73,93 +74,119 @@ npm run build |
73 | 74 | ``` |
74 | 75 |
|
75 | 76 |
|
76 | | -## $dispatch, methods |
77 | | - addFileUpload |
78 | 77 |
|
79 | | - removeFileUpload |
| 78 | +# Setting |
80 | 79 |
|
81 | | - fileUploadProgress |
82 | 80 |
|
83 | | - beforeFileUpload |
| 81 | +## Props |
| 82 | +``` html |
| 83 | +<file-upload |
| 84 | + title="Add upload files" |
84 | 85 |
|
85 | | - afterFileUpload |
| 86 | + name="post file name" |
86 | 87 |
|
| 88 | + drop="Boolean (true = $parent) or Element or Css Selector" |
87 | 89 |
|
| 90 | + extensions="Array or String or Regular" |
88 | 91 |
|
| 92 | + post-action="./post.method" |
89 | 93 |
|
90 | | -## Setting |
| 94 | + put-action="./put.method" |
91 | 95 |
|
92 | | -### Data |
93 | | -``` js |
94 | | - { |
95 | | - files: [ |
96 | | - { |
97 | | - id: 'String', // Read only |
98 | | - name: 'filename String', |
99 | | - size: 'filesize Number', |
100 | | - progress: 'progress String', // Read only |
101 | | - speed: "Speed Number", // Read only |
102 | | - active: 'active Boolean', |
103 | | - error: 'error String', |
104 | | - errno: 'errno String', |
105 | | - success: 'success Boolean', // Read only |
106 | | - data: 'Response data Object or String', // Read only |
107 | | - request: { |
108 | | - headers: { |
109 | | - "X-Csrf-Token": "xxxx", |
110 | | - }, |
111 | | - data: { |
112 | | - "_csrf_token": "xxxxxx", |
113 | | - }, |
114 | | - }, |
115 | | - } |
116 | | - ], |
| 96 | + accept="accept" |
117 | 97 |
|
| 98 | + multiple="true or false" |
118 | 99 |
|
119 | | - // Global |
120 | | - request: { |
121 | | - headers: { |
122 | | - "X-Csrf-Token": "xxxx", |
123 | | - }, |
124 | | - data: { |
125 | | - "_csrf_token": "xxxxxx", |
126 | | - }, |
127 | | - }, |
| 100 | + size="max Size" |
128 | 101 |
|
| 102 | + timeout="3600000" |
129 | 103 |
|
130 | | - active: false, |
| 104 | + events="Object" |
131 | 105 |
|
132 | | - uploaded: true, // Read only |
| 106 | + headers="Request headers object" |
133 | 107 |
|
134 | | - dropActive: false, // Read only |
135 | | - } |
| 108 | + data="Request data object" |
| 109 | + |
| 110 | + files="Upload files" |
| 111 | + > |
| 112 | +</file-upload> |
136 | 113 | ``` |
137 | 114 |
|
138 | 115 |
|
139 | | -### Props |
140 | | -``` html |
141 | | - <file-upload :title="Add upload files" :name="file" :drop="Boolean (true = $parent) or Element or Css Selector" :extensions="Array or String or Regular" :post-action="./post.method" :put-action="./put.method" :accept="accept" :multiple="true" :size="size" :timeout="3600000"></file-upload> |
142 | | -``` |
143 | 116 |
|
| 117 | + |
| 118 | +### Props events |
| 119 | +``` js |
| 120 | + events: { |
| 121 | + add(file, component) { |
| 122 | + console.log('add'); |
| 123 | + if (this.auto) { |
| 124 | + component.active = true; |
| 125 | + } |
| 126 | + file.headers['X-Filename'] = encodeURIComponent(file.name) |
| 127 | + file.data.finename = file.name |
| 128 | + |
| 129 | + // file.putAction = 'xxx' |
| 130 | + // file.postAction = 'xxx' |
| 131 | + }, |
| 132 | + progress(file, component) { |
| 133 | + console.log('progress ' + file.progress); |
| 134 | + }, |
| 135 | + after(file, component) { |
| 136 | + console.log('after'); |
| 137 | + }, |
| 138 | + before(file, component) { |
| 139 | + console.log('before'); |
| 140 | + } |
| 141 | + } |
144 | 142 | ``` |
145 | | - title="Add upload files" |
146 | 143 |
|
147 | | - name="post file name" |
148 | 144 |
|
149 | | - drop="Boolean (true = $parent) or Element or Css Selector" |
150 | 145 |
|
151 | | - extensions="Array or String or Regular" :post-action="./post.method" |
| 146 | +### Props files |
| 147 | +``` js |
| 148 | + [ |
| 149 | + { |
| 150 | + id: 'String', // Read only |
| 151 | + name: 'filename String', |
| 152 | + size: 'filesize Number', // -1 = html4 |
| 153 | + progress: 'progress String', // Read only |
| 154 | + speed: "Speed Number", // Read only |
| 155 | + active: 'active Boolean', // set active = fasle abort upload |
| 156 | + error: 'error String', // Read only |
| 157 | + success: 'success Boolean', // Read only |
| 158 | + data: 'Response data Object or String', // Read only |
| 159 | + putAction: 'String uri', |
| 160 | + postAction: 'String uri', |
| 161 | + timeout: "Number", |
| 162 | + headers: { |
| 163 | + "X-Csrf-Token": "xxxx", |
| 164 | + }, |
| 165 | + data: { |
| 166 | + "_csrf_token": "xxxxxx", |
| 167 | + }, |
| 168 | + |
| 169 | + xhr: "False or XMLHttpRequest object", // html5 |
| 170 | + iframe: "False or Element object", // html4 |
| 171 | + file: "undefined or File object" // html5 |
| 172 | + el: "undefined or Input object" |
| 173 | + } |
| 174 | + ] |
| 175 | +``` |
152 | 176 |
|
153 | | - post-action="./post.method" |
154 | 177 |
|
155 | | - put-action="./put.method" |
156 | 178 |
|
157 | | - accept="accept" |
158 | 179 |
|
159 | | - multiple="true or false" |
160 | 180 |
|
161 | | - size="max Size" |
| 181 | +## data |
| 182 | +``` js |
| 183 | + { |
| 184 | + mode: 'html5', // html5 or html4 |
162 | 185 |
|
163 | | - timeout="3600000" |
| 186 | + active: false, // set active = fasle abort upload |
164 | 187 |
|
| 188 | + uploaded: true, // Read only |
| 189 | + |
| 190 | + dropActive: false, // Read only |
| 191 | + } |
165 | 192 | ``` |
0 commit comments