elementui type=
elementui type 属性
在 Element UI 中,type 属性用于定义组件的样式或行为,具体作用因组件而异。以下是常见组件中 type 属性的用法:
Button 按钮
type 定义按钮的样式,可选值包括:
primary:主要按钮(蓝色)success:成功按钮(绿色)warning:警告按钮(橙色)danger:危险按钮(红色)info:信息按钮(灰色)text:文字按钮(无背景)
<el-button type="primary">主要按钮</el-button>
<el-button type="danger">危险按钮</el-button>
Alert 警告
type 定义警告框的类型,可选值包括:
success:成功提示warning:警告提示info:信息提示error:错误提示
<el-alert type="success" title="成功提示"></el-alert>
<el-alert type="error" title="错误提示"></el-alert>
Tag 标签
type 定义标签的样式,可选值与 Button 类似:
success/info/warning/danger
<el-tag type="success">成功标签</el-tag>
<el-tag type="danger">危险标签</el-tag>
Progress 进度条
type 定义进度条的显示形式:
line:直线型(默认)circle:环形dashboard:仪表盘型
<el-progress type="circle" :percentage="50"></el-progress>
Message 消息提示
通过调用方法时传入 type:
success/warning/info/error
this.$message({ type: 'success', message: '操作成功' });
注意事项
- 不同组件的
type值可能不同,需参考具体组件文档。 - 部分组件的
type会影响功能而不仅是样式(如radio组件的button类型)。 - 自定义主题时,
type对应的颜色可能被覆盖。
如需更详细的组件 type 用法,建议查阅 Element UI 官方文档对应组件的 API 部分。







