GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [Doc] update contribution guide (#1250) · present/vant@d972100

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .github
    • MARKDOWN.md
  • docs
    • markdown
      • contribution.zh-CN.md
      • style-guide.zh-CN.md
    • src
      • doc.config.js
      • docs-entry.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.github/MARKDOWN.md‎

Copy file name to clipboardExpand all lines: .github/MARKDOWN.md
-42Lines changed: 0 additions & 42 deletions
This file was deleted.
Collapse file

‎docs/markdown/contribution.zh-CN.md‎

Copy file name to clipboard
+144Lines changed: 144 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
## 开发指南
2+
3+
首先感谢你使用 Vant。
4+
5+
以下是关于向 Vant 提交代码的指南。在向 Vant 提交 Issue 或者 PR 之前,请先花几分钟时间阅读以下文字。
6+
7+
### Issue 规范
8+
9+
- 遇到问题时,请先确认这个问题已经在 issue 中有记录或者已被修复
10+
- 提 Issue 时,请用简短的语言描述遇到的问题,并添加出现问题时的环境和复现步骤
11+
12+
### Pull Request 规范
13+
14+
- 如果遇到问题,建议保持你的 PR 足够小。保证一个 PR 只解决一个问题或只添加一个功能
15+
- 当新增组件或者修改原有组件时,记得增加或者修改测试代码,保证代码的稳定
16+
- 在 PR 中请添加合适的描述,并关联相关的 Issue
17+
18+
### 初始化项目
19+
20+
```bash
21+
git clone [email protected]:youzan/vant.git
22+
23+
cd vant
24+
25+
# 安装依赖
26+
npm run bootstrap
27+
28+
# 本地开发模式
29+
npm run dev
30+
```
31+
32+
浏览器访问 [http://localhost:8080](http://localhost:8080) 就可以看到所有组件的示例了。
33+
34+
### 目录结构
35+
36+
- 仓库的组件代码位于 packages 下,每个组件一个文件夹
37+
- 组件样式代码位于 packages/vant-css/src 下,vant-css 也会在发布时单独发包
38+
- docs 目录下是文档网站的代码,本地开发时可以在目录下运行 npm run dev 开启文档网站
39+
40+
项目目录大致如下:
41+
42+
```
43+
vant
44+
├─ build # 构建脚本
45+
├─ docs # 文档网站
46+
├─ packages # 组件文件
47+
├─ test # 单元测试
48+
└─ types # 类型定义
49+
```
50+
51+
### 添加新组件
52+
53+
添加新组件时,请按照下面的目录结构组织文件,并在 `docs/src/doc.config.js` 中配置组件名称
54+
55+
```
56+
packages
57+
|- button
58+
| ├─ demo # 示例代码
59+
| ├─ test # 单元测试
60+
| ├─ zh-CN.md # 中文文档
61+
| ├─ en-US.md # 英文文档
62+
| └─ index.vue # 组件入口
63+
└─ vant-css
64+
├─ index.css # 样式入口
65+
└─ button.css # 组件样式
66+
```
67+
68+
### 组件文档
69+
70+
组件文档采用 markdown 格式,内容包括使用示例以及 `API` 等。
71+
72+
##### 1. 标题规范
73+
74+
文档标题从 `h2`(即 `##` 标题 )开始,每往下一级多加一个 `#` 号。
75+
76+
##### 2. 组件描述
77+
78+
大标题下面是对组件的一句话简要描述。
79+
80+
##### 3. 使用指南
81+
82+
如果组件需要使用指南,放在组件描述下方,另起一个二级标题。
83+
84+
##### 4. 代码演示
85+
86+
书写代码演示时,建议从简单用法开始介绍,不要上来就同时使用一大堆 API,会让人觉得难以上手。并且一个示例只演示一个 API 的使用方法,如无特殊需求不要在一个示例中同时演示多个 API 混合使用。
87+
88+
```html
89+
<van-button :size="size">
90+
Large
91+
</van-button>
92+
```
93+
94+
```javascript
95+
export default {
96+
data() {
97+
return {
98+
size: 'large'
99+
};
100+
}
101+
};
102+
```
103+
104+
#### 5. API 说明
105+
106+
组件的 API 说明,请以表格的形式书写,表格包含以下列:
107+
108+
| 参数 | 说明 | 类型 | 默认值 |
109+
| ------------ | ------------- | -------- | ---------- |
110+
| visible | 是否可见 | bool | `false` |
111+
112+
#### 6. Event 说明
113+
114+
组件的 Event 说明,请以表格的形式书写,表格包含以下列:
115+
116+
| 事件名 | 说明 | 参数 |
117+
|-----------|-----------|-----------|
118+
| click | 点击按钮时触发 | event:事件对象 |
119+
120+
### 实用技巧
121+
122+
#### 组件互相引用
123+
124+
比如说 `Dialog` 里面引用了 `Button` 组件,直接写相对路径引用即可。
125+
126+
```js
127+
import Button from '../button';
128+
```
129+
130+
#### 组件创建
131+
132+
Vant 中的组件会通过 `create` 方法统一创建,`create` 方法会在选项文件中注入基本的依赖和方法。
133+
134+
```js
135+
import create from '../utils/create';
136+
137+
export default create({
138+
name: 'button'
139+
});
140+
```
141+
142+
#### 样式
143+
144+
组件样式使用 `precss 2.0` 作为预处理器,具体语法请参考 [precss 文档](https://github.com/jonathantneal/precss).
Collapse file

‎.github/STYLE_GUIDE.zh-CN.md‎ ‎docs/markdown/style-guide.zh-CN.md‎.github/STYLE_GUIDE.zh-CN.md renamed to docs/markdown/style-guide.zh-CN.md

Copy file name to clipboardExpand all lines: docs/markdown/style-guide.zh-CN.md
+3-3Lines changed: 3 additions & 3 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 风格指南
1+
## 风格指南
22

33
在参与 Vant 开发时,请遵守约定的单文件组件风格指南,指南内容节选自 [Vue 官方风格指南](https://cn.vuejs.org/v2/style-guide)
44

@@ -47,13 +47,13 @@ MyComponent.vue
4747
components/
4848
|- TodoList.vue
4949
|- TodoItem.vue
50-
|- TodoButton.vue
50+
└─ TodoButton.vue
5151
5252
// good
5353
components/
5454
|- TodoList.vue
5555
|- TodoListItem.vue
56-
|- TodoListItemButton.vue
56+
└─ TodoListItemButton.vue
5757
```
5858

5959
### 自闭合组件
Collapse file

‎docs/src/doc.config.js‎

Copy file name to clipboardExpand all lines: docs/src/doc.config.js
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ module.exports = {
4545
path: '/theme',
4646
title: '定制主题'
4747
},
48+
{
49+
path: '/contribution',
50+
title: '开发指南'
51+
},
52+
{
53+
path: '/style-guide',
54+
title: '风格指南'
55+
},
4856
{
4957
path: '/demo',
5058
title: '示例页面'
Collapse file

‎docs/src/docs-entry.js‎

Copy file name to clipboardExpand all lines: docs/src/docs-entry.js
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ export default {
33
'changelog.en-US': () => import('../markdown/changelog.en-US.md'),
44
'changelog.generated': () => import('../markdown/changelog.generated.md'),
55
'changelog.zh-CN': () => import('../markdown/changelog.zh-CN.md'),
6+
'contribution.zh-CN': () => import('../markdown/contribution.zh-CN.md'),
67
'intro.en-US': () => import('../markdown/intro.en-US.md'),
78
'intro.zh-CN': () => import('../markdown/intro.zh-CN.md'),
89
'quickstart.en-US': () => import('../markdown/quickstart.en-US.md'),
910
'quickstart.zh-CN': () => import('../markdown/quickstart.zh-CN.md'),
11+
'style-guide.zh-CN': () => import('../markdown/style-guide.zh-CN.md'),
1012
'theme.en-US': () => import('../markdown/theme.en-US.md'),
1113
'theme.zh-CN': () => import('../markdown/theme.zh-CN.md'),
1214
'actionsheet.en-US': () => import('../../packages/actionsheet/en-US.md'),

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.