Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Element
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林焕东
Element
Commits
a87b6e2e
Commit
a87b6e2e
authored
Mar 09, 2017
by
baiyaaaaa
Committed by
杨奕
Mar 09, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add custom http requrest
parent
4ac6fed6
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
11 additions
and
8 deletions
+11
-8
examples/docs/en-US/upload.md
examples/docs/en-US/upload.md
+1
-0
examples/docs/zh-CN/upload.md
examples/docs/zh-CN/upload.md
+1
-0
packages/upload/src/ajax.js
packages/upload/src/ajax.js
+1
-4
packages/upload/src/index.vue
packages/upload/src/index.vue
+4
-2
packages/upload/src/upload.vue
packages/upload/src/upload.vue
+4
-2
No files found.
examples/docs/en-US/upload.md
View file @
a87b6e2e
...
@@ -364,6 +364,7 @@ thumbnail-mode | whether thumbnail is displayed | boolean | — | false
...
@@ -364,6 +364,7 @@ thumbnail-mode | whether thumbnail is displayed | boolean | — | false
file-list | default uploaded files, i.e:
[
{name: 'food.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'}
]
| array | — |
[]
file-list | default uploaded files, i.e:
[
{name: 'food.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'}
]
| array | — |
[]
list-type | type of fileList | string | text/picture/picture-card | text |
list-type | type of fileList | string | text/picture/picture-card | text |
auto-upload | whether to auto upload file | boolean | — | true |
auto-upload | whether to auto upload file | boolean | — | true |
http-request | override default xhr behavior, allowing you to implement your own upload-file's request | function | — | — |
### Events
### Events
| Event Name | Description | Parameters |
| Event Name | Description | Parameters |
...
...
examples/docs/zh-CN/upload.md
View file @
a87b6e2e
...
@@ -413,6 +413,7 @@
...
@@ -413,6 +413,7 @@
| list-type | 文件列表的类型 | string | text/picture/picture-card | text |
| list-type | 文件列表的类型 | string | text/picture/picture-card | text |
| auto-upload | 是否在选取文件后立即进行上传 | boolean | — | true |
| auto-upload | 是否在选取文件后立即进行上传 | boolean | — | true |
| file-list | 上传的文件列表, 例如:
[
{name: 'food.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'}
]
| array | — |
[]
|
| file-list | 上传的文件列表, 例如:
[
{name: 'food.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'}
]
| array | — |
[]
|
| http-request | 覆盖默认的上传行为,可以自定义上传的实现 | function | — | — |
### Methods
### Methods
| 方法名 | 说明 | 参数 |
| 方法名 | 说明 | 参数 |
...
...
packages/upload/src/ajax.js
View file @
a87b6e2e
...
@@ -75,14 +75,11 @@ export default function upload(option) {
...
@@ -75,14 +75,11 @@ export default function upload(option) {
const
headers
=
option
.
headers
||
{};
const
headers
=
option
.
headers
||
{};
// if (headers['X-Requested-With'] !== null) {
// xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
// }
for
(
let
item
in
headers
)
{
for
(
let
item
in
headers
)
{
if
(
headers
.
hasOwnProperty
(
item
)
&&
headers
[
item
]
!==
null
)
{
if
(
headers
.
hasOwnProperty
(
item
)
&&
headers
[
item
]
!==
null
)
{
xhr
.
setRequestHeader
(
item
,
headers
[
item
]);
xhr
.
setRequestHeader
(
item
,
headers
[
item
]);
}
}
}
}
xhr
.
send
(
formData
);
xhr
.
send
(
formData
);
return
xhr
;
}
}
packages/upload/src/index.vue
View file @
a87b6e2e
...
@@ -85,7 +85,8 @@ export default {
...
@@ -85,7 +85,8 @@ export default {
listType
:
{
listType
:
{
type
:
String
,
type
:
String
,
default
:
'
text
'
// text,picture,picture-card
default
:
'
text
'
// text,picture,picture-card
}
},
httpRequest
:
Function
},
},
data
()
{
data
()
{
...
@@ -228,7 +229,8 @@ export default {
...
@@ -228,7 +229,8 @@ export default {
'
on-success
'
:
this
.
handleSuccess
,
'
on-success
'
:
this
.
handleSuccess
,
'
on-error
'
:
this
.
handleError
,
'
on-error
'
:
this
.
handleError
,
'
on-preview
'
:
this
.
onPreview
,
'
on-preview
'
:
this
.
onPreview
,
'
on-remove
'
:
this
.
handleRemove
'
on-remove
'
:
this
.
handleRemove
,
httpRequest
:
this
.
httpRequest
},
},
ref
:
'
upload-inner
'
ref
:
'
upload-inner
'
};
};
...
...
packages/upload/src/upload.vue
View file @
a87b6e2e
...
@@ -37,7 +37,8 @@ export default {
...
@@ -37,7 +37,8 @@ export default {
},
},
fileList
:
Array
,
fileList
:
Array
,
autoUpload
:
Boolean
,
autoUpload
:
Boolean
,
listType
:
String
listType
:
String
,
httpRequest
:
Function
},
},
data
()
{
data
()
{
...
@@ -93,7 +94,8 @@ export default {
...
@@ -93,7 +94,8 @@ export default {
}
}
},
},
post
(
rawFile
)
{
post
(
rawFile
)
{
ajax
({
const
request
=
this
.
httpRequest
||
ajax
;
request
({
headers
:
this
.
headers
,
headers
:
this
.
headers
,
withCredentials
:
this
.
withCredentials
,
withCredentials
:
this
.
withCredentials
,
file
:
rawFile
,
file
:
rawFile
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment