Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ant-design-pro-vue
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tianzhuanghu
ant-design-pro-vue
Commits
f729bbf2
Commit
f729bbf2
authored
Dec 11, 2018
by
Sendya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: avatar list
parent
f9c51edf
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
106 additions
and
25 deletions
+106
-25
Item.vue
src/components/AvatarList/Item.vue
+31
-9
List.vue
src/components/AvatarList/List.vue
+39
-10
index.js
src/components/AvatarList/index.js
+2
-0
index.less
src/components/AvatarList/index.less
+8
-4
Home.vue
src/views/Home.vue
+26
-2
No files found.
src/components/AvatarList/Item.vue
View file @
f729bbf2
<
template
>
<div>
item
</div>
<li
:class=
"[prefixCls, size]"
>
<slot>
<tooltip>
<template
slot=
"title"
>
{{
tips
}}
</
template
>
<avatar
:size=
"size !== 'mini' && size || 20"
:src=
"src"
/>
</tooltip>
</slot>
</li>
</template>
<
script
>
import
Avatar
from
'ant-design-vue/es/avatar'
import
Tooltip
from
'ant-design-vue/es/tooltip'
export
default
{
name
:
"AvatarItem"
,
components
:
{
Avatar
,
Tooltip
},
props
:
{
prefixCls
:
{
type
:
String
,
default
:
'ant-pro-avatar-list-item'
},
tips
:
{
type
:
String
,
default
:
''
,
...
...
@@ -15,12 +31,18 @@
},
src
:
{
type
:
String
,
required
:
true
default
:
''
}
},
data
()
{
return
{
size
:
this
.
$parent
.
size
}
},
watch
:
{
'$parent.size'
(
val
)
{
this
.
size
=
val
}
}
}
</
script
>
\ No newline at end of file
<
style
scoped
>
</
style
>
\ No newline at end of file
src/components/AvatarList/List.vue
View file @
f729bbf2
<
template
>
<div>
<div
:class=
"[prefixCls]"
>
<ul>
<slot></slot>
<template
v-if=
"maxLength > 0 && slotsSize > maxLength"
>
<avatar-item
:size=
"size"
>
<avatar
:size=
"size !== 'mini' && size || 20"
:style=
"excessItemsStyle"
>
{{
`+${maxLength
}
`
}}
<
/avatar
>
<
/avatar-item
>
<
/template
>
<
/ul
>
<
/div
>
<
/template
>
<
script
>
import
Avatar
from
'ant-design-vue/es/avatar'
import
Avatar
List
Item
from
'./Item'
import
AvatarItem
from
'./Item'
export
default
{
AvatarItem
,
name
:
"AvatarList"
,
components
:
{
Avatar
,
Avatar
List
Item
AvatarItem
}
,
props
:
{
prefixCls
:
{
type
:
String
,
default
:
'ant-pro-avatar-list'
}
,
/**
* 头像大小 类型: large、small 、mini, default
* 默认值: default
*/
size
:
{
type
:
String
,
type
:
[
String
,
Number
]
,
default
:
'default'
}
,
/**
...
...
@@ -28,24 +40,40 @@
*/
maxLength
:
{
type
:
Number
,
default
:
3
default
:
0
}
,
/**
*
额外 CSS
风格
*
多余的项目
风格
*/
excessItemsStyle
:
{
type
:
Object
,
default
:
()
=>
{}
default
:
()
=>
{
return
{
color
:
'#f56a00'
,
backgroundColor
:
'#fde3cf'
}
}
}
}
,
data
()
{
return
{
slotsSize
:
0
}
}
,
created
()
{
this
.
slotsSize
=
this
.
$slots
.
default
.
length
this
.
splitSlots
()
}
,
methods
:
{
splitSlots
()
{
if
(
this
.
maxLength
!==
0
&&
this
.
slotsSize
>
this
.
maxLength
)
{
this
.
$slots
.
default
=
this
.
$slots
.
default
.
slice
(
0
,
this
.
maxLength
)
}
}
}
}
<
/script
>
<
style
scoped
>
<
style
lang
=
"less"
scoped
>
<
/style>
\ No newline at end of file
src/components/AvatarList/index.js
View file @
f729bbf2
import
AvatarList
from
'./List'
import
"./index.less"
export
default
AvatarList
\ No newline at end of file
src/components/AvatarList/index.less
View file @
f729bbf2
...
...
@@ -7,8 +7,10 @@
display: inline-block;
ul {
list-style: none;
display: inline-block;
margin-left: 8px;
padding: 0;
margin: 0 0 0 8px;
font-size: 0;
}
}
...
...
@@ -23,20 +25,21 @@
:global {
.ant-avatar {
border: 1px solid #fff;
cursor: pointer;
}
}
.large {
&
.large {
width: @avatar-size-lg;
height: @avatar-size-lg;
}
.small {
&
.small {
width: @avatar-size-sm;
height: @avatar-size-sm;
}
.mini {
&
.mini {
width: 20px;
height: 20px;
...
...
@@ -54,3 +57,4 @@
}
}
}
src/views/Home.vue
View file @
f729bbf2
...
...
@@ -43,8 +43,27 @@
</a-card>
<a-divider>
例子
</a-divider>
<a-divider>
AvatarList
</a-divider>
<a-card>
<avatar-list
:max-length=
"3"
>
<avatar-list-item
tips=
"Jake"
src=
"https://gw.alipayobjects.com/zos/rmsportal/zOsKZmFRdUtvpqCImOVY.png"
/>
<avatar-list-item
tips=
"Andy"
src=
"https://gw.alipayobjects.com/zos/rmsportal/sfjbOqnsXXJgNCjCzDBL.png"
/>
<avatar-list-item
tips=
"Niko"
src=
"https://gw.alipayobjects.com/zos/rmsportal/kZzEzemZyKLKFsojXItE.png"
/>
<avatar-list-item
tips=
"Niko"
src=
"https://gw.alipayobjects.com/zos/rmsportal/kZzEzemZyKLKFsojXItE.png"
/>
<avatar-list-item
tips=
"Niko"
src=
"https://gw.alipayobjects.com/zos/rmsportal/kZzEzemZyKLKFsojXItE.png"
/>
<avatar-list-item
tips=
"Niko"
src=
"https://gw.alipayobjects.com/zos/rmsportal/kZzEzemZyKLKFsojXItE.png"
/>
<avatar-list-item
tips=
"Niko"
src=
"https://gw.alipayobjects.com/zos/rmsportal/kZzEzemZyKLKFsojXItE.png"
/>
</avatar-list>
<a-divider
type=
"vertical"
style=
"margin: 0 16px"
/>
<avatar-list
size=
"mini"
>
<avatar-list-item
tips=
"Jake"
src=
"https://gw.alipayobjects.com/zos/rmsportal/zOsKZmFRdUtvpqCImOVY.png"
/>
<avatar-list-item
tips=
"Andy"
src=
"https://gw.alipayobjects.com/zos/rmsportal/sfjbOqnsXXJgNCjCzDBL.png"
/>
<avatar-list-item
tips=
"Niko"
src=
"https://gw.alipayobjects.com/zos/rmsportal/kZzEzemZyKLKFsojXItE.png"
/>
</avatar-list>
</a-card>
</div>
</
template
>
...
...
@@ -52,11 +71,16 @@
// @ is an alias to /src
import
Trend
from
'@/components/Trend'
import
AvatarList
from
'@/components/AvatarList'
const
AvatarListItem
=
AvatarList
.
AvatarItem
export
default
{
name
:
'Home'
,
components
:
{
Trend
Trend
,
AvatarList
,
AvatarListItem
}
}
</
script
>
...
...
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