Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wanjj_1210
ant-design
提交
af30f55e
A
ant-design
项目概览
wanjj_1210
/
ant-design
与 Fork 源项目一致
从无法访问的项目Fork
通知
10
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
ant-design
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
af30f55e
编写于
9月 01, 2015
作者:
Y
yiminghe
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
optimize
上级
5b76d65e
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
36 addition
and
34 deletion
+36
-34
components/select/index.md
components/select/index.md
+1
-0
components/upload/demo/defaultFileList.md
components/upload/demo/defaultFileList.md
+2
-2
components/upload/demo/fileList.md
components/upload/demo/fileList.md
+2
-2
components/upload/index.jsx
components/upload/index.jsx
+28
-27
components/upload/index.md
components/upload/index.md
+3
-3
未找到文件。
components/select/index.md
浏览文件 @
af30f55e
...
...
@@ -35,6 +35,7 @@
| allowClear | 显示清除按钮 | | false |
| placeholder | 选择框默认文字 | string | 无 |
| searchPlaceholder | 搜索框默认文字 | string | 无 |
| optionFilterProp | 输入项过滤对应的 option 属性 | string | value |
| combobox | 输入框自动提示模式 | | false |
| size | 选择框大小 | String | 无 |
...
...
components/upload/demo/defaultFileList.md
浏览文件 @
af30f55e
...
...
@@ -18,12 +18,12 @@ var props = {
}
},
defaultFileList
:
[{
uid
:
12345
,
uid
:
-
1
,
name
:
'
xxx.png
'
,
status
:
'
done
'
,
url
:
'
http://www.baidu.com/xxx.png
'
},
{
uid
:
12346
,
uid
:
-
2
,
name
:
'
yyy.png
'
,
status
:
'
done
'
,
url
:
'
http://www.baidu.com/yyy.png
'
...
...
components/upload/demo/fileList.md
浏览文件 @
af30f55e
...
...
@@ -15,7 +15,7 @@
````
jsx
var
Upload
=
antd
.
Upload
;
var
fileList
=
[{
uid
:
123
,
uid
:
-
1
,
name
:
'
xxx.png
'
,
status
:
'
done
'
,
url
:
'
http://www.baidu.com/xxx.png
'
...
...
@@ -32,7 +32,7 @@ var MyUpload = React.createClass({
// 1. 上传列表数量的限制
// 只显示最近上传的一个,旧的会被新的顶掉
fileList
=
fileList
.
slice
(
-
1
);
fileList
=
fileList
.
slice
(
-
2
);
// 2. 读取远程路径并显示链接
fileList
=
fileList
.
map
(
function
(
file
)
{
...
...
components/upload/index.jsx
浏览文件 @
af30f55e
...
...
@@ -16,10 +16,10 @@ const AntUpload = React.createClass({
};
},
onStart
(
file
)
{
let
nextFileList
=
this
.
state
.
fileList
;
let
nextFileList
=
this
.
state
.
fileList
.
concat
()
;
file
.
status
=
'
uploading
'
;
nextFileList
.
push
(
file
);
this
.
props
.
onChange
({
this
.
onChange
({
file
:
file
,
fileList
:
nextFileList
});
...
...
@@ -31,30 +31,34 @@ const AntUpload = React.createClass({
let
index
=
fileList
.
indexOf
(
targetItem
);
if
(
index
!==
-
1
)
{
fileList
.
splice
(
index
,
1
);
return
fileList
;
}
return
fileList
;
return
null
;
},
onSuccess
(
response
,
file
)
{
let
fileList
=
this
.
state
.
fileList
.
concat
();
Message
.
success
(
file
.
name
+
'
上传完成。
'
);
let
targetItem
=
getFileItem
(
file
,
fileList
);
targetItem
.
status
=
'
done
'
;
targetItem
.
response
=
response
;
// 解析出文件上传后的远程地址
if
(
typeof
this
.
props
.
urlResolver
===
'
function
'
)
{
targetItem
.
url
=
this
.
props
.
urlResolver
(
response
);
// 之前已经删除
if
(
targetItem
)
{
targetItem
.
status
=
'
done
'
;
targetItem
.
response
=
response
;
this
.
onChange
({
file
:
targetItem
,
fileList
:
this
.
state
.
fileList
});
}
this
.
onChange
({
file
:
targetItem
,
fileList
:
this
.
state
.
fileList
});
},
onProgress
(
e
,
file
)
{
this
.
onChange
({
event
:
e
,
file
:
file
,
fileList
:
this
.
state
.
fileList
});
let
fileList
=
this
.
state
.
fileList
;
let
targetItem
=
getFileItem
(
file
,
fileList
);
if
(
targetItem
)
{
this
.
onChange
({
event
:
e
,
file
:
file
,
fileList
:
this
.
state
.
fileList
});
}
},
onError
(
error
,
response
,
file
)
{
Message
.
error
(
file
.
name
+
'
上传失败。
'
);
...
...
@@ -64,10 +68,12 @@ const AntUpload = React.createClass({
},
handleRemove
(
file
)
{
let
fileList
=
this
.
removeFile
(
file
);
this
.
onChange
({
file
:
file
,
fileList
:
fileList
});
if
(
fileList
)
{
this
.
onChange
({
file
:
file
,
fileList
:
fileList
});
}
},
onChange
(
info
)
{
// 1. 有设置外部属性时不改变 fileList
...
...
@@ -88,11 +94,6 @@ const AntUpload = React.createClass({
data
:
{},
accept
:
''
,
onChange
:
noop
,
urlResolver
:
function
(
response
)
{
try
{
return
JSON
.
parse
(
response
).
url
;
}
catch
(
e
)
{}
}
};
},
componentWillReceiveProps
(
nextProps
)
{
...
...
@@ -129,7 +130,7 @@ const AntUpload = React.createClass({
</
Upload
>
</
div
>
<
UploadList
items
=
{
this
.
state
.
fileList
}
onRemove
=
{
this
.
handleRemove
}
/>
onRemove
=
{
this
.
handleRemove
}
/>
</
div
>
);
}
...
...
components/upload/index.md
浏览文件 @
af30f55e
...
...
@@ -43,9 +43,9 @@
```
js
{
uid
:
'
uid
'
,
// 文件唯一标识
uid
:
'
uid
'
,
// 文件唯一标识
,建议设置为负数,防止和内部产生的 id 冲突
name
:
'
xx.png
'
// 文件名
status
:
'
done
'
,
// 状态:uploading done
removed
status
:
'
done
'
,
// 状态:uploading done
response
:
'
{"status":"success"}
'
// 服务端响应内容
}
```
...
...
@@ -55,4 +55,4 @@
## 显示下载链接
默认会解析服务器返回数据的
`body.url`
作为下载链接,需要自行配置请使用 fileList
属性进行展示控制。
请使用 fileList 属性设置数组项的 url
属性进行展示控制。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录