跳到主要内容

· 阅读需 2 分钟

标题(atx 样式)

# h1
## h2
### h3
#### h4
##### h5
###### h6

标题(settext 样式)

Header 1
========
Header 2
--------

块引用

> This is
> a blockquote
>
> > Nested
> > Blockquote
-------

无序列表

* Item 1
* Item 2
* item 3a
* item 3b

或者

- Item 1
- Item 2
----------

或者

+ Item 1
+ Item 2

或者

- [ ] Checkbox off
- [x] Checkbox on

有序列表

1. Item 1
2. Item 2
a. item 3a
b. item 3b

链接

[link](http://google.com)
[link][google]
[google]: http://google.com.
<http://google.com>

重点

~*italic*
_italic_

**bold**
__bold__

`inline code`
~~struck out~~

| Left column | Center column | Right column |
|:------------|:-------------:|-------------:|
| Cell 1 | Centered | $1600 |
| Cell 2 | Cell 3 | $12 |

简约风格

Left column | Center column | Right column 
:---:|:---:|:---:
Cell 1 | Centered | $1600
Cell 2 | Cell 3 | $12

图片

![GitHub Logo](/images/logo.png)
![Alt Text](url)

带链接的图片

[![GitHub Logo](/images/logo.png)](https://github.com/)

[![Alt Text](image_url)](link_url)

参考款式

![alt text][/images/logo.png]

[logo]: /images/logo.png "Logo Title"

反斜杠转义

人物逃脱描述
\ \反斜杠
``反引号
**星号
__下划线
{}{}大括号
[][]方括号
()()括弧
##井号
++加号
——-减号(连字符)
..
!感叹号

删除线、下划线、脚注

~~删除线~~
<u>带下划线文本</u>
[^要注明的文本]

更多语法

· 阅读需 1 分钟
**
* 比较两个版本号的大小
* @param {string} v1
* @param {string} v2
* @returns {0|1|-1} 0表示v1 = v2,1表示v1 > v2,-1表示v1 < v2
*
* compareVersion('1.1.0', '1.1.0'); // => 0
* compareVersion('1.20.0', '1.2.20'); // => 1
* compareVersion('v2.0.30', 'v1.9.10'); // => 1
* compareVersion('v1.1.40', 'v1.2.0'); // => -1
*/
function compareVersion(v1, v2) {
let cpResult;
let i = 0;
const arr1 = v1.replace(/[^0-9.]/, '').split('.');
const arr2 = v2.replace(/[^0-9.]/, '').split('.');
while (true) {
const s1 = arr1[i];
const s2 = arr2[i++];
if (s1 === undefined || s2 === undefined) {
cpResult = arr1.length - arr2.length;
break;
}
if (s1 === s2) continue;
cpResult = s1 - s2;
break;
}
// eslint-disable-next-line
return cpResult > 0 ? 1 : cpResult === 0 ? 0 : -1;
}
标签: