|
|
@@ -8,11 +8,10 @@ Avatars can be used to represent people or objects. It supports images, Icons, o
|
|
|
|
|
|
```javascript
|
|
|
import { createApp } from 'vue';
|
|
|
-import { Avatar, Icon } from '@nutui/nutui';
|
|
|
+import { Avatar } from '@nutui/nutui';
|
|
|
|
|
|
const app = createApp();
|
|
|
app.use(Avatar);
|
|
|
-app.use(Icon);
|
|
|
```
|
|
|
|
|
|
### Size
|
|
|
@@ -23,18 +22,15 @@ Support three sizes:small、normal、large
|
|
|
|
|
|
```html
|
|
|
<template>
|
|
|
- <nut-avatar
|
|
|
- size="large"
|
|
|
- icon="https://img12.360buyimg.com/imagetools/jfs/t1/143702/31/16654/116794/5fc6f541Edebf8a57/4138097748889987.png"
|
|
|
- ></nut-avatar>
|
|
|
- <nut-avatar
|
|
|
- size="normal"
|
|
|
- icon="https://img12.360buyimg.com/imagetools/jfs/t1/143702/31/16654/116794/5fc6f541Edebf8a57/4138097748889987.png"
|
|
|
- ></nut-avatar>
|
|
|
- <nut-avatar
|
|
|
- size="small"
|
|
|
- icon="https://img12.360buyimg.com/imagetools/jfs/t1/143702/31/16654/116794/5fc6f541Edebf8a57/4138097748889987.png"
|
|
|
- ></nut-avatar>
|
|
|
+ <nut-avatar size="large">
|
|
|
+ <img src="https://img12.360buyimg.com/imagetools/jfs/t1/143702/31/16654/116794/5fc6f541Edebf8a57/4138097748889987.png" />
|
|
|
+ </nut-avatar>
|
|
|
+ <nut-avatar size="normal">
|
|
|
+ <img src="https://img12.360buyimg.com/imagetools/jfs/t1/143702/31/16654/116794/5fc6f541Edebf8a57/4138097748889987.png" />
|
|
|
+ </nut-avatar>
|
|
|
+ <nut-avatar size="small">
|
|
|
+ <img src="https://img12.360buyimg.com/imagetools/jfs/t1/143702/31/16654/116794/5fc6f541Edebf8a57/4138097748889987.png" />
|
|
|
+ </nut-avatar>
|
|
|
</template>
|
|
|
```
|
|
|
|
|
|
@@ -48,8 +44,8 @@ Support two shapes:square、round
|
|
|
|
|
|
```html
|
|
|
<template>
|
|
|
- <nut-avatar icon="my" shape="square"></nut-avatar>
|
|
|
- <nut-avatar icon="my" shape="round"></nut-avatar>
|
|
|
+ <nut-avatar shape="square"><My /></nut-avatar>
|
|
|
+ <nut-avatar shape="round"><My /></nut-avatar>
|
|
|
</template>
|
|
|
```
|
|
|
|
|
|
@@ -63,12 +59,11 @@ Support three types:picture、icon、letter
|
|
|
|
|
|
```html
|
|
|
<template>
|
|
|
- <nut-avatar
|
|
|
- url="https://img12.360buyimg.com/imagetools/jfs/t1/143702/31/16654/116794/5fc6f541Edebf8a57/4138097748889987.png"
|
|
|
- >
|
|
|
+ <nut-avatar>
|
|
|
+ <img src="https://img12.360buyimg.com/imagetools/jfs/t1/196430/38/8105/14329/60c806a4Ed506298a/e6de9fb7b8490f38.png" />
|
|
|
</nut-avatar>
|
|
|
- <nut-avatar icon="my"></nut-avatar>
|
|
|
- <nut-avatar>N</nut-avatar>
|
|
|
+ <nut-avatar><My /></nut-avatar>
|
|
|
+ <nut-avatar>王</nut-avatar>
|
|
|
</template>
|
|
|
```
|
|
|
|
|
|
@@ -82,8 +77,8 @@ Icon and letter types can have custom colors and background colors
|
|
|
|
|
|
```html
|
|
|
<template>
|
|
|
- <nut-avatar class="demo-avatar" icon="my" color="#fff" bg-color="#FA2C19"></nut-avatar>
|
|
|
- <nut-avatar color="rgb(245, 106, 0)" bg-color="rgb(253, 227, 207)">U</nut-avatar>
|
|
|
+ <nut-avatar class="demo-avatar" bg-color="#FA2C19"><My color="#fff"/></nut-avatar>
|
|
|
+ <nut-avatar color="rgb(245, 106, 0)" bg-color="rgb(253, 227, 207)">小明</nut-avatar>
|
|
|
</template>
|
|
|
```
|
|
|
|
|
|
@@ -96,10 +91,10 @@ Icon and letter types can have custom colors and background colors
|
|
|
```html
|
|
|
<template>
|
|
|
<nut-badge value="8">
|
|
|
- <nut-avatar icon="my" shape="square"></nut-avatar>
|
|
|
+ <nut-avatar shape="square"><My /></nut-avatar>
|
|
|
</nut-badge>
|
|
|
<nut-badge dot>
|
|
|
- <nut-avatar icon="my" shape="square"></nut-avatar>
|
|
|
+ <nut-avatar shape="square"><My /></nut-avatar>
|
|
|
</nut-badge>
|
|
|
</template>
|
|
|
```
|
|
|
@@ -113,25 +108,23 @@ Icon and letter types can have custom colors and background colors
|
|
|
```html
|
|
|
<template>
|
|
|
<nut-avatar-group span="-4">
|
|
|
- <nut-avatar
|
|
|
- url="https://img12.360buyimg.com/imagetools/jfs/t1/196430/38/8105/14329/60c806a4Ed506298a/e6de9fb7b8490f38.png"
|
|
|
- >
|
|
|
+ <nut-avatar>
|
|
|
+ <img src="https://img12.360buyimg.com/imagetools/jfs/t1/196430/38/8105/14329/60c806a4Ed506298a/e6de9fb7b8490f38.png" />
|
|
|
</nut-avatar>
|
|
|
- <nut-avatar icon="my"></nut-avatar>
|
|
|
- <nut-avatar color="rgb(245, 106, 0)" bg-color="rgb(253, 227, 207)">U</nut-avatar>
|
|
|
+ <nut-avatar><My /></nut-avatar>
|
|
|
+ <nut-avatar color="rgb(245, 106, 0)" bg-color="rgb(253, 227, 207)">小明</nut-avatar>
|
|
|
</nut-avatar-group>
|
|
|
<nut-avatar-group
|
|
|
max-count="3"
|
|
|
max-color="#fff"
|
|
|
max-bgColor="#498ff2"
|
|
|
>
|
|
|
- <nut-avatar
|
|
|
- url="https://img12.360buyimg.com/imagetools/jfs/t1/196430/38/8105/14329/60c806a4Ed506298a/e6de9fb7b8490f38.png"
|
|
|
- >
|
|
|
+ <nut-avatar>
|
|
|
+ <img src="https://img12.360buyimg.com/imagetools/jfs/t1/196430/38/8105/14329/60c806a4Ed506298a/e6de9fb7b8490f38.png" />
|
|
|
</nut-avatar>
|
|
|
- <nut-avatar icon="my"></nut-avatar>
|
|
|
- <nut-avatar color="rgb(245, 106, 0)" bg-color="rgb(253, 227, 207)">U</nut-avatar>
|
|
|
- <nut-avatar icon="my"></nut-avatar>
|
|
|
+ <nut-avatar><My /></nut-avatar>
|
|
|
+ <nut-avatar color="rgb(245, 106, 0)" bg-color="rgb(253, 227, 207)">小明</nut-avatar>
|
|
|
+ <nut-avatar><My /></nut-avatar>
|
|
|
</nut-avatar-group>
|
|
|
</template>
|
|
|
```
|
|
|
@@ -149,13 +142,12 @@ Icon and letter types can have custom colors and background colors
|
|
|
zIndex="right"
|
|
|
max-content="..."
|
|
|
>
|
|
|
- <nut-avatar
|
|
|
- url="https://img12.360buyimg.com/imagetools/jfs/t1/196430/38/8105/14329/60c806a4Ed506298a/e6de9fb7b8490f38.png"
|
|
|
- >
|
|
|
+ <nut-avatar>
|
|
|
+ <img src="https://img12.360buyimg.com/imagetools/jfs/t1/196430/38/8105/14329/60c806a4Ed506298a/e6de9fb7b8490f38.png" />
|
|
|
</nut-avatar>
|
|
|
- <nut-avatar icon="my"></nut-avatar>
|
|
|
- <nut-avatar color="rgb(245, 106, 0)" bg-color="rgb(253, 227, 207)">U</nut-avatar>
|
|
|
- <nut-avatar icon="my"></nut-avatar>
|
|
|
+ <nut-avatar><My /></nut-avatar>
|
|
|
+ <nut-avatar color="rgb(245, 106, 0)" bg-color="rgb(253, 227, 207)">小明</nut-avatar>
|
|
|
+ <nut-avatar><My /></nut-avatar>
|
|
|
</nut-avatar-group>
|
|
|
</template>
|
|
|
```
|
|
|
@@ -169,7 +161,7 @@ Icon and letter types can have custom colors and background colors
|
|
|
```html
|
|
|
<template>
|
|
|
<nut-cell>
|
|
|
- <nut-avatar icon="my" @active-avatar="handleClick"></nut-avatar>
|
|
|
+ <nut-avatar @click="handleClick"><My /></nut-avatar>
|
|
|
</nut-cell>
|
|
|
</template>
|
|
|
<script lang="ts">
|
|
|
@@ -196,12 +188,9 @@ Icon and letter types can have custom colors and background colors
|
|
|
| Attribute | Description | Type | Default |
|
|
|
| -------- | ------------------------------------------------------------------- | ------ | ------ |
|
|
|
| size | The size of the avatar,eg `large`、`normal`、`small`,and numbers | String | Number | normal |
|
|
|
-| shape | The shape of avatar,eg `square`、`round ` | String | round |
|
|
|
-| color | The colors of Icon and letter types | String | #666 |
|
|
|
-| bg-color | The background colors of Icon and letter types | String | #eee |
|
|
|
-| url | The address of the image for an image avatar or image element | String | - |
|
|
|
-| alt | This attribute defines the alternative text describing the image | String | - |
|
|
|
-| icon | Custom icon type for an icon avatar, Refer to the name attribute of Icon component | String | - |
|
|
|
+| shape | shape of avatar,eg `square`、`round ` | String | round |
|
|
|
+| color | color of text | String | #666 |
|
|
|
+| bg-color | background color | String | #eee |
|
|
|
|
|
|
### AvatarGroup Props
|
|
|
|
|
|
@@ -211,14 +200,13 @@ Icon and letter types can have custom colors and background colors
|
|
|
| max-content | When the number of avatars exceeds, a avatar folding element will appear,The content of this element can be `...`、`more`、`+N` | String | +N |
|
|
|
| size | The size of the avatar,eg `large`、`normal`、`small`,支持直接输入数字 | String | Number | normal |
|
|
|
| shape | The shape of avatar,eg `square`、`round` | String | round |
|
|
|
-| max-color | The colors of Icon and letter types | String | #666 |
|
|
|
-| max-bg-color | The background colors of Icon and letter types | String | #eee |
|
|
|
+| max-color | color of text | String | #666 |
|
|
|
+| max-bg-color | background color | String | #eee |
|
|
|
| span | Distance between avatars | String | -8 |
|
|
|
| zIndex | Hierarchy direction between avatar group,eg `left`、`right` | String | left |
|
|
|
|
|
|
-### Avatar Events
|
|
|
+### Avatar Slots
|
|
|
|
|
|
-| Event | Description | Arguments |
|
|
|
-| ------------- | ----------------------------- | --------- |
|
|
|
-| active-avatar | Emitted when cell is clicked | event |
|
|
|
-| on-error | Handler when img load error | event |
|
|
|
+| Name | Description |
|
|
|
+| ------------- | ----------------------------- |
|
|
|
+| default | default slot for img, icon or text |
|