# MMAvatar 头像
用来代表用户或事物,支持图片、图标或字符展示。
# Props
# IMMAvatarProps
属性 | 类型 | 默认值 | 必传 | 说明 |
---|---|---|---|---|
shape | EMMAvatarShape | keyof typeof EMMAvatarShape | square | 否 | 形状 |
size | EMMAvatarSize | keyof typeof EMMAvatarSize | number | 否 | 大小 | |
icon | MMIconFontName | 否 | icon | |
src | string | 否 | 图片类头像的资源地址 | |
text | string | 否 | 头像内文本内容 | |
avatarStyle | Properties<string | number> | 否 | 额外样式 |
# 代码示例
import { View } from "@tarojs/components";
import MMAvatar from "../../components/avatar";
import PageDemoBlock from "../../components/pageComponents/pageDemoBlock";
import MMPageContainer from "../../components/pageComponents/pageContainer";
export default () => {
return (
<MMPageContainer title="MMAvatar 头像">
<PageDemoBlock title="不同尺寸">
<View
style={{
display: "flex",
flexDirection: "row",
justifyContent: "space-around",
alignItems: "flex-end",
}}
>
<MMAvatar size="small" />
<MMAvatar />
<MMAvatar size="large" />
<MMAvatar size={64} />
</View>
</PageDemoBlock>
<PageDemoBlock title="圆形">
<MMAvatar shape="circle" />
</PageDemoBlock>
</MMPageContainer>
);
};