원클릭으로
element-plus-dev-standards
强制遵循Element Plus开发规范:使用CSS变量而非硬编码值、不修改组件自带样式、不使用内联样式、使用标准CSS类和scoped样式。在涉及Element Plus样式修改时必须调用此技能。
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
强制遵循Element Plus开发规范:使用CSS变量而非硬编码值、不修改组件自带样式、不使用内联样式、使用标准CSS类和scoped样式。在涉及Element Plus样式修改时必须调用此技能。
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Enforce form validation before submit. Validate first, return early on failure, and only then run the async submit logic inside try/catch so validation errors aren’t swallowed and misreported.
一站式 UI/UX 优化专家,自动执行完整的设计优化流程。Invoke when user wants comprehensive UI/UX improvements, full page optimization, or 'make this look professional'.
Set up and run end-to-end (E2E) tests for web applications using Playwright. Invoke when user wants to create E2E tests, set up testing framework, or run automated browser tests.
强制遵循Y-SSO前端开发规范:Vue组件规范、CSS变量使用、BEM命名、导入顺序、文件结构等。仅在修改 frontend/src/ 目录下文件时调用。
YWeb DDD 分层架构与 API 设计规范。在创建或修改 API 路由、Service 层、领域模型、DTO 时使用。涵盖瘦 API 原则、服务层拆分、Model 设计、DTO 转换、响应格式等。
YWeb ORM 使用规范。在编写数据库模型定义、CRUD 操作、查询过滤、分页、软删除、事务管理、批量操作、关系定义等数据层代码时使用。基于 SQLAlchemy 的 Active Record 模式。
| name | element-plus-dev-standards |
| description | 强制遵循Element Plus开发规范:使用CSS变量而非硬编码值、不修改组件自带样式、不使用内联样式、使用标准CSS类和scoped样式。在涉及Element Plus样式修改时必须调用此技能。 |
本文档汇总了所有 Element Plus 组件开发规范,包括表格、表单、对话框等组件的使用标准。
规则: 列宽度必须 >= 标签字符数 × 40px
<!-- 正确 -->
<el-table-column label="主组织" width="120" /> <!-- 3×40=120 -->
<el-table-column label="员工编码" width="160" /> <!-- 4×40=160 -->
<!-- 错误 -->
<el-table-column label="主组织" width="90" /> <!-- 3×40=120, 90<120 -->
例外情况:
min-width 的弹性列表格级别: 必须设置 tooltip-effect="light"
<el-table :data="tableData" tooltip-effect="light">
列级别: 以下类型必须添加 show-overflow-tooltip
description, desc, remark, noteaddress, url, link, pathcontent, detail, infomin-width > 150px 时<el-table-column prop="description" label="描述" min-width="180" show-overflow-tooltip />
<el-table-column prop="address" label="地址" min-width="200" show-overflow-tooltip />
不需要添加的场景:
template 的列使用 v-if 控制,避免重复空提示:
<!-- 正确 -->
<el-table v-if="list.length > 0" :data="list">
...
</el-table>
<EmptyState v-else title="暂无数据" />
<!-- 错误 - 会显示两个空提示 -->
<el-table :data="list">
...
</el-table>
<EmptyState v-if="list.length === 0" />
使用 :deep() 进行样式穿透:
.data-card :deep(.el-table) {
background-color: var(--white);
border: none;
}
.data-card :deep(.el-table thead th) {
background-color: var(--light-gray);
border-bottom: 1px solid var(--border_color);
}
推荐方案 - 校验错误与 API 错误分离:
const handleSubmit = async () => {
if (!formRef.value) return
// Step 1: 表单校验 - 失败直接返回
const isValid = await formRef.value.validate().catch(() => false)
if (!isValid) return // Element Plus 自动显示错误
// Step 2: 校验通过后才设置 loading
submitLoading.value = true
try {
// API 调用 - 只有 API 错误会被 catch
const response = await api.create(data)
ElMessage.success('操作成功')
} catch (error) {
// 只处理 API 错误
handleApiError(error, '操作失败')
} finally {
submitLoading.value = false
}
}
禁止方案 - 混合错误处理:
// 不要这样做
const handleSubmit = async () => {
try {
await formRef.value.validate() // 校验错误会进入 catch
// ... API 调用
} catch (error) {
// 校验错误和 API 错误混在一起
if (error.name || error.code) return // 难以区分
handleApiError(error, '失败')
}
}
使用 label 插槽添加提示:
<el-form-item>
<template #label>
函数名
<el-tooltip content="用于筛选并查看某个缓存函数的统计与条目详情。" placement="top">
<el-icon class="hint-icon"><QuestionFilled /></el-icon>
</el-tooltip>
</template>
<el-select v-model="selectedFunctionName" />
</el-form-item>
防止自动填充:
<el-input
v-model="password"
type="password"
placeholder="请输入密码"
show-password
autocomplete="new-password"
:input-attrs="{
autocomplete: 'new-password',
'data-lpignore': 'true',
'data-form-type': 'other'
}"
/>
属性说明:
autocomplete="new-password" - HTML5 标准,告诉浏览器这是新密码data-lpignore="true" - 阻止 LastPass 自动填充data-form-type="other" - 告诉浏览器这不是登录表单<el-dialog
v-model="visible"
title="标题"
width="500px"
align-center
destroy-on-close
>
<template #default>
<!-- 内容 -->
</template>
<template #footer>
<el-button @click="visible = false">取消</el-button>
<el-button type="primary" @click="handleConfirm">确定</el-button>
</template>
</el-dialog>
对于复杂表单,优先使用抽屉:
<el-drawer
v-model="drawerVisible"
title="编辑"
size="820px"
destroy-on-close
>
<!-- 内容 -->
</el-drawer>
只有图标时使用 circle 类型:
<el-button circle @click="toggleCollapse">
<el-icon>
<component :is="isCollapse ? ArrowRight : ArrowLeft" />
</el-icon>
</el-button>
type 属性(primary, success, warning, danger, info).el-button 类名/* 正确 */
.custom-class {
color: var(--el-color-primary);
font-size: var(--el-font-size-base);
}
/* 错误 */
.custom-class {
color: #409eff;
font-size: 14px;
}
所有组件样式必须添加 scoped:
<style scoped>
.custom-class {
/* ... */
}
</style>
<!-- 正确 -->
<div class="custom-class">
<!-- 错误 -->
<div style="color: red; font-size: 14px;">
必须调用:
建议调用:
element-plus-migration - 版本升级迁移问题y-sso-frontend-standards - 项目整体前端规范ui-ux-pro-max - UI/UX 优化