在 GitHub 里 设置 Issue 的“固定格式”,主要有三种方式,从「简单 → 专业 → 强约束」逐级升级 👇 (实际开发里最常用的是 Issue Templates + Issue Forms)
适合:
在仓库根目录创建:
.github/
└── ISSUE_TEMPLATE/
└── bug_report.md
bug_report.md---
name: 🐞 Bug 报告
about: 提交一个 Bug
title: "[Bug] "
labels: bug
assignees: ''
---
## 🐞 问题描述
清楚简要地描述问题。
## 🔁 复现步骤
1. …
2. …
3. …
## ✅ 期望行为
描述你期望发生什么。
## 🖥 环境信息
- OS:
- 浏览器 / 运行环境:
- 版本:
## 📸 截图
如果有,请附上截图。
📌 效果:
❌ 缺点:
👉 强烈推荐,尤其是团队/开源项目
.github/
└── ISSUE_TEMPLATE/
└── bug_report.yml
bug_report.ymlname: 🐞 Bug Report
description: 提交一个 Bug
title: "[Bug]: "
labels: ["bug"]
body:
- type: textarea
id: description
attributes:
label: 问题描述
description: 请清晰描述你遇到的问题
placeholder: 发生了什么?
validations:
required: true
- type: textarea
id: steps
attributes:
label: 复现步骤
placeholder: |
1. …
2. …
3. …
validations:
required: true
- type: input
id: version
attributes:
label: 版本号
placeholder: v1.0.0
validations:
required: true
- type: dropdown
id: os
attributes:
label: 操作系统
options:
- Windows
- macOS
- Linux
validations:
required: true
📌 优点:
❌ 注意:
如果你 不想让用户随便新建 Issue:
创建 .github/ISSUE_TEMPLATE/config.yml
blank_issues_enabled: false
contact_links:
- name: 💬 讨论区
url: https://github.com/你的仓库/discussions
about: 请先在讨论区提问
效果:
.github/ISSUE_TEMPLATE/
├── bug_report.yml
├── feature_request.yml
├── question.yml
└── config.yml
比如:
可以配合:
如果你是个人或小团队: 👉 直接用 Issue Forms(YAML)
如果是开源项目: 👉 Issue Forms + 禁用空白 Issue