Skip to content

Commit 50fb298

Browse files
committed
文档: 更新文档
1 parent d638f2e commit 50fb298

File tree

9 files changed

+146
-10
lines changed

9 files changed

+146
-10
lines changed

docs/.vitepress/config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
import type { UserConfig } from 'vitepress'
2+
// @ts-ignore
3+
import codetabs from 'markdown-it-codetabs'
24

35
const config: UserConfig = {
46
base: '/vue3-oop/',
57
title: 'VUE3-OOP',
68
description: 'vue3 oop是vue3开发进入面向对象阶段',
9+
markdown: {
10+
lineNumbers: false,
11+
config(md) {
12+
md.use(codetabs)
13+
},
14+
},
715
themeConfig: {
816
nav: [
917
{ text: '指南', link: '/guide/', activeMatch: '^/guide/' },

docs/.vitepress/theme/codetabs.scss

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
.code-tabs {
2+
border-radius: 3px;
3+
[class^='language-'],
4+
input {
5+
display: none;
6+
}
7+
input:checked + [class^='language-'] {
8+
display: block;
9+
}
10+
label {
11+
color: rgba(191, 191, 191, 1);
12+
}
13+
input:checked + label {
14+
color: rgba(38, 38, 38, 1);
15+
}
16+
ul {
17+
font-size: 0;
18+
padding: 0;
19+
white-space: nowrap;
20+
overflow: auto;
21+
user-select: none;
22+
border-bottom: 1px solid rgb(240, 240, 240);
23+
}
24+
li {
25+
list-style: none;
26+
display: inline-block;
27+
position: relative;
28+
}
29+
label {
30+
cursor: pointer;
31+
user-select: none;
32+
display: inline-block;
33+
padding: 2px 5px;
34+
margin: 5px;
35+
font-size: 14px;
36+
}
37+
li ~ li::before {
38+
content: '';
39+
height: 12px;
40+
width: 1px;
41+
background: rgba(191, 191, 191, 1);
42+
position: absolute;
43+
top: 50%;
44+
transform: translate(-50%, -50%);
45+
}
46+
}

docs/.vitepress/theme/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import './codetabs.scss'
2+
import theme from 'vitepress/dist/client/theme-default'
3+
4+
export default theme

docs/guide/component.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,15 @@
1-
#
1+
## 定义
2+
3+
组件必须继承 **`VueComponent`**
4+
5+
```typescript
6+
import { VueComponent } from 'vue3-oop'
7+
8+
class Foo extends VueComponent {
9+
render() {
10+
return (
11+
<div>我是组件UI</div>
12+
)
13+
}
14+
}
15+
```

example/main.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@ class HomeChild extends VueComponent<HomeChild_Props> {
4444
super()
4545
}
4646

47+
@Link() div?: ClassType<HTMLDivElement>
48+
4749
render() {
4850
return (
49-
<div style={{ marginTop: '40px' }}>
51+
<div style={{ marginTop: '40px' }} ref="div">
5052
<h1>子组件</h1>
5153
<h4>子组件属性是:{this.props.size}</h4>
5254
<h4>父组件外部服务状态: {this.parentCountService.count}</h4>

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,11 @@
7070
"eslint-plugin-prettier": "^4.0.0",
7171
"injection-js": "^2.4.0",
7272
"lint-staged": "^12.1.2",
73+
"markdown-it-codetabs": "^1.2.0",
7374
"npm-run-all": "^4.1.5",
7475
"prettier": "^2.5.1",
7576
"rimraf": "^3.0.2",
77+
"sass": "^1.44.0",
7678
"standard-version": "^9.3.2",
7779
"typescript": "^4.5.2",
7880
"vite": "^2.6.14",

src/extends/component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,4 @@ export type ComponentSlots<T extends { props: any }> = T extends { props: infer
105105
: never
106106

107107
/** 为了阻止ts把不相关的类也解析到metadata数据中,用这个工具类型包装一下类 */
108-
export type ClassType<T extends Record<string, any>> = T
108+
export type ClassType<T> = T

tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"sourceMap": true,
99
"resolveJsonModule": true,
1010
"esModuleInterop": true,
11-
"lib": ["esnext", "dom"],
12-
"types": ["vite/client", "@abraham/reflection"],
11+
"lib": ["esnext", "dom", "ES5"],
12+
"types": ["vite/client"],
1313
"experimentalDecorators": true,
1414
"emitDecoratorMetadata": true,
1515
"useDefineForClassFields": false,

yarn.lock

Lines changed: 65 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,14 @@ ant-design-vue@^3.0.0-alpha.11:
10441044
vue-types "^3.0.0"
10451045
warning "^4.0.0"
10461046

1047+
anymatch@~3.1.2:
1048+
version "3.1.2"
1049+
resolved "https://registry.npmmirror.com/anymatch/download/anymatch-3.1.2.tgz#c0557c096af32f106198f4f4e2a383537e378716"
1050+
integrity sha1-wFV8CWrzLxBhmPT04qODU343hxY=
1051+
dependencies:
1052+
normalize-path "^3.0.0"
1053+
picomatch "^2.0.4"
1054+
10471055
app-root-path@~3.0.0:
10481056
version "3.0.0"
10491057
resolved "https://registry.npmmirror.com/app-root-path/download/app-root-path-3.0.0.tgz#210b6f43873227e18a4b810a032283311555d5ad"
@@ -1111,6 +1119,11 @@ balanced-match@^1.0.0:
11111119
resolved "https://registry.npmmirror.com/balanced-match/download/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
11121120
integrity sha1-6D46fj8wCzTLnYf2FfoMvzV2kO4=
11131121

1122+
binary-extensions@^2.0.0:
1123+
version "2.2.0"
1124+
resolved "https://registry.npmmirror.com/binary-extensions/download/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d"
1125+
integrity sha1-dfUC7q+f/eQvyYgpZFvk6na9ni0=
1126+
11141127
brace-expansion@^1.1.7:
11151128
version "1.1.11"
11161129
resolved "https://registry.npmmirror.com/brace-expansion/download/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
@@ -1119,7 +1132,7 @@ brace-expansion@^1.1.7:
11191132
balanced-match "^1.0.0"
11201133
concat-map "0.0.1"
11211134

1122-
braces@^3.0.1:
1135+
braces@^3.0.1, braces@~3.0.2:
11231136
version "3.0.2"
11241137
resolved "https://registry.npmmirror.com/braces/download/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107"
11251138
integrity sha1-NFThpGLujVmeI23zNs2epPiv4Qc=
@@ -1246,6 +1259,21 @@ chardet@^0.7.0:
12461259
resolved "https://registry.npmmirror.com/chardet/download/chardet-0.7.0.tgz?cache=0&sync_timestamp=1634639163489&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Fchardet%2Fdownload%2Fchardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e"
12471260
integrity sha1-kAlISfCTfy7twkJdDSip5fDLrZ4=
12481261

1262+
"chokidar@>=3.0.0 <4.0.0":
1263+
version "3.5.2"
1264+
resolved "https://registry.npmmirror.com/chokidar/download/chokidar-3.5.2.tgz#dba3976fcadb016f66fd365021d91600d01c1e75"
1265+
integrity sha1-26OXb8rbAW9m/TZQIdkWANAcHnU=
1266+
dependencies:
1267+
anymatch "~3.1.2"
1268+
braces "~3.0.2"
1269+
glob-parent "~5.1.2"
1270+
is-binary-path "~2.1.0"
1271+
is-glob "~4.0.1"
1272+
normalize-path "~3.0.0"
1273+
readdirp "~3.6.0"
1274+
optionalDependencies:
1275+
fsevents "~2.3.2"
1276+
12491277
ci-info@^1.5.0:
12501278
version "1.6.0"
12511279
resolved "https://registry.npmmirror.com/ci-info/download/ci-info-1.6.0.tgz#2ca20dbb9ceb32d4524a683303313f0304b1e497"
@@ -2635,7 +2663,7 @@ gitconfiglocal@^1.0.0:
26352663
dependencies:
26362664
ini "^1.3.2"
26372665

2638-
glob-parent@^5.1.2:
2666+
glob-parent@^5.1.2, glob-parent@~5.1.2:
26392667
version "5.1.2"
26402668
resolved "https://registry.npmmirror.com/glob-parent/download/glob-parent-5.1.2.tgz?cache=0&sync_timestamp=1632953971963&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Fglob-parent%2Fdownload%2Fglob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4"
26412669
integrity sha1-hpgyxYA0/mikCTwX3BXoNA2EAcQ=
@@ -2871,6 +2899,11 @@ ignore@^5.1.4, ignore@^5.1.8:
28712899
resolved "https://registry.npmmirror.com/ignore/download/ignore-5.1.8.tgz#f150a8b50a34289b33e22f5889abd4d8016f0e57"
28722900
integrity sha1-8VCotQo0KJsz4i9YiavU2AFvDlc=
28732901

2902+
immutable@^4.0.0:
2903+
version "4.0.0"
2904+
resolved "https://registry.npmmirror.com/immutable/download/immutable-4.0.0.tgz#b86f78de6adef3608395efb269a91462797e2c23"
2905+
integrity sha1-uG943mre82CDle+yaakUYnl+LCM=
2906+
28742907
import-fresh@^3.0.0, import-fresh@^3.2.1:
28752908
version "3.3.0"
28762909
resolved "https://registry.npmmirror.com/import-fresh/download/import-fresh-3.3.0.tgz#37162c25fcb9ebaa2e6e53d5b4d88ce17d9e0c2b"
@@ -2974,6 +3007,13 @@ is-bigint@^1.0.1:
29743007
dependencies:
29753008
has-bigints "^1.0.1"
29763009

3010+
is-binary-path@~2.1.0:
3011+
version "2.1.0"
3012+
resolved "https://registry.npmmirror.com/is-binary-path/download/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09"
3013+
integrity sha1-6h9/O4DwZCNug0cPhsCcJU+0Wwk=
3014+
dependencies:
3015+
binary-extensions "^2.0.0"
3016+
29773017
is-boolean-object@^1.1.0:
29783018
version "1.1.2"
29793019
resolved "https://registry.npmmirror.com/is-boolean-object/download/is-boolean-object-1.1.2.tgz#5c6dc200246dd9321ae4b885a114bb1f75f63719"
@@ -3033,7 +3073,7 @@ is-fullwidth-code-point@^4.0.0:
30333073
resolved "https://registry.npmmirror.com/is-fullwidth-code-point/download/is-fullwidth-code-point-4.0.0.tgz#fae3167c729e7463f8461ce512b080a49268aa88"
30343074
integrity sha1-+uMWfHKedGP4RhzlErCApJJoqog=
30353075

3036-
is-glob@^4.0.0, is-glob@^4.0.1, is-glob@^4.0.3:
3076+
is-glob@^4.0.0, is-glob@^4.0.1, is-glob@^4.0.3, is-glob@~4.0.1:
30373077
version "4.0.3"
30383078
resolved "https://registry.npmmirror.com/is-glob/download/is-glob-4.0.3.tgz?cache=0&sync_timestamp=1632934382080&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Fis-glob%2Fdownload%2Fis-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084"
30393079
integrity sha1-ZPYeQsu7LuwgcanawLKLoeZdUIQ=
@@ -3493,6 +3533,11 @@ map-obj@^4.0.0:
34933533
resolved "https://registry.npmmirror.com/map-obj/download/map-obj-4.3.0.tgz#9304f906e93faae70880da102a9f1df0ea8bb05a"
34943534
integrity sha1-kwT5Buk/qucIgNoQKp8d8OqLsFo=
34953535

3536+
markdown-it-codetabs@^1.2.0:
3537+
version "1.2.0"
3538+
resolved "https://registry.npmmirror.com/markdown-it-codetabs/download/markdown-it-codetabs-1.2.0.tgz#e1c2626dee5e726d76c2739c425ebfd4443d2f1e"
3539+
integrity sha1-4cJibe5ecm12wnOcQl6/1EQ9Lx4=
3540+
34963541
memorystream@^0.3.1:
34973542
version "0.3.1"
34983543
resolved "https://registry.npmmirror.com/memorystream/download/memorystream-0.3.1.tgz#86d7090b30ce455d63fbae12dda51a47ddcaf9b2"
@@ -3717,7 +3762,7 @@ normalize-path@^1.0.0:
37173762
resolved "https://registry.npmmirror.com/normalize-path/download/normalize-path-1.0.0.tgz#32d0e472f91ff345701c15a8311018d3b0a90379"
37183763
integrity sha1-MtDkcvkf80VwHBWoMRAY07CpA3k=
37193764

3720-
normalize-path@^3.0.0:
3765+
normalize-path@^3.0.0, normalize-path@~3.0.0:
37213766
version "3.0.0"
37223767
resolved "https://registry.npmmirror.com/normalize-path/download/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65"
37233768
integrity sha1-Dc1p/yOhybEf0JeDFmRKA4ghamU=
@@ -4031,7 +4076,7 @@ picocolors@^1.0.0:
40314076
resolved "https://registry.npmmirror.com/picocolors/download/picocolors-1.0.0.tgz?cache=0&sync_timestamp=1634093437726&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Fpicocolors%2Fdownload%2Fpicocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c"
40324077
integrity sha1-y1vcdP8/UYkiNur3nWi8RFZKuBw=
40334078

4034-
picomatch@^2.2.2, picomatch@^2.2.3:
4079+
picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.2.2, picomatch@^2.2.3:
40354080
version "2.3.0"
40364081
resolved "https://registry.npmmirror.com/picomatch/download/picomatch-2.3.0.tgz#f1f061de8f6a4bf022892e2d128234fb98302972"
40374082
integrity sha1-8fBh3o9qS/AiiS4tEoI0+5gwKXI=
@@ -4228,6 +4273,13 @@ readable-stream@^2.0.0, readable-stream@~2.3.6:
42284273
string_decoder "~1.1.1"
42294274
util-deprecate "~1.0.1"
42304275

4276+
readdirp@~3.6.0:
4277+
version "3.6.0"
4278+
resolved "https://registry.npmmirror.com/readdirp/download/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7"
4279+
integrity sha1-dKNwvYVxFuJFspzJc0DNQxoCpsc=
4280+
dependencies:
4281+
picomatch "^2.2.1"
4282+
42314283
redent@^1.0.0:
42324284
version "1.0.0"
42334285
resolved "https://registry.npmjs.org/redent/-/redent-1.0.0.tgz#cf916ab1fd5f1f16dfb20822dd6ec7f730c2afde"
@@ -4407,6 +4459,14 @@ safe-buffer@~5.1.0, safe-buffer@~5.1.1:
44074459
resolved "https://registry.npmmirror.com/safer-buffer/download/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a"
44084460
integrity sha1-RPoWGwGHuVSd2Eu5GAL5vYOFzWo=
44094461

4462+
sass@^1.44.0:
4463+
version "1.44.0"
4464+
resolved "https://registry.npmmirror.com/sass/download/sass-1.44.0.tgz#619aa0a2275c097f9af5e6b8fe8a95e3056430fb"
4465+
integrity sha512-0hLREbHFXGQqls/K8X+koeP+ogFRPF4ZqetVB19b7Cst9Er8cOR0rc6RU7MaI4W1JmUShd1BPgPoeqmmgMMYFw==
4466+
dependencies:
4467+
chokidar ">=3.0.0 <4.0.0"
4468+
immutable "^4.0.0"
4469+
44104470
scroll-into-view-if-needed@^2.2.25:
44114471
version "2.2.28"
44124472
resolved "https://registry.npmmirror.com/scroll-into-view-if-needed/download/scroll-into-view-if-needed-2.2.28.tgz#5a15b2f58a52642c88c8eca584644e01703d645a"

0 commit comments

Comments
 (0)