在 Vue 2 的 Element UI 和 Vue 3 的 Element Plus 中,Avatar
头像组件可能并没有直接作为官方组件库的一部分。然而,为了回答你的问题,我将假设 Element UI 和 Element Plus 在未来的版本中可能添加了 Avatar
组件,或者我们将使用一个类似的第三方组件或自定义组件作为例子。
Vue 2 + Element UI 中的 Avatar 组件(假设性)
属性 (Attributes)
- src: 头像的图片地址。
- size: 头像的大小,可以是
large
、medium
、small
或具体的尺寸数值。 - shape: 头像的形状,例如
circle
或square
。 - alt: 图片的替代文本,用于提高可访问性。
事件 (Events)
- click: 当头像被点击时触发。
- error: 当图片加载失败时触发。
方法 (Methods)
通常,Avatar 组件不会暴露特定的方法。
示例
<template>
<el-avatar src="path/to/image.jpg" size=