Skip to content

Commit 9139b42

Browse files
committed
feat: 支持多重组件继承,修改异步组件的定义
1 parent 9745dc3 commit 9139b42

File tree

7 files changed

+459
-406
lines changed

7 files changed

+459
-406
lines changed

docs/guide/component.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,12 @@ class Foo extends VueComponent<Foo_Props> {
160160

161161
## 异步组件
162162

163-
异步组件需配合`vue`提供的`Suspense`组件使用,只需要组件内定义`init` 方法并且返回`promise`结果
163+
异步组件需配合`vue`提供的`Suspense`组件使用,需要标记组件的`async: true`, 并且组件内定义`init` 方法并且返回`promise`结果
164164

165165
```tsx
166166
class Foo extends VueComponent {
167+
static async = true
168+
167169
async init() {
168170
await new Promise(r => setTimeout(r, 5000))
169171
}

example/module/basic/hello-world/hello-world.view.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,33 @@
11
import { Mut, VueComponent } from 'vue3-oop'
22
import { Button, Card, Input } from 'ant-design-vue'
33

4+
export class Base extends VueComponent {
5+
@Mut() count = 1
6+
render() {
7+
return <div>base{this.count}</div>
8+
}
9+
}
10+
11+
export class Child1 extends Base {
12+
render() {
13+
return <div onClick={() => this.count++}>{super.render()}</div>
14+
}
15+
}
16+
17+
export class Child2 extends Child1 {
18+
render() {
19+
return (
20+
<>
21+
<h2>this is child2</h2>
22+
{super.render()}
23+
</>
24+
)
25+
}
26+
}
27+
428
export default class HelloWorldView extends VueComponent {
29+
static async = true
30+
531
@Mut() count = 1
632

733
async init() {
@@ -21,6 +47,9 @@ export default class HelloWorldView extends VueComponent {
2147
<Button type={'primary'} onClick={() => this.count--}>
2248
-
2349
</Button>
50+
<Child2></Child2>
51+
<Child1></Child1>
52+
<Base></Base>
2453
</Card>
2554
)
2655
}

package.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,41 +50,41 @@
5050
"license": "MIT",
5151
"devDependencies": {
5252
"@abraham/reflection": "^0.10.0",
53-
"@commitlint/cli": "^17.0.2",
54-
"@commitlint/config-conventional": "^17.0.2",
53+
"@commitlint/cli": "^17.0.3",
54+
"@commitlint/config-conventional": "^17.0.3",
5555
"@nexhome/yorkie": "^2.0.8",
5656
"@release-it/conventional-changelog": "^5.0.0",
5757
"@types/lodash-es": "^4.17.6",
5858
"@types/markdown-it": "^12.2.3",
5959
"@types/node": "^18.0.0",
6060
"@types/prettier": "^2.6.3",
61-
"@typescript-eslint/eslint-plugin": "^5.28.0",
62-
"@typescript-eslint/parser": "^5.28.0",
61+
"@typescript-eslint/eslint-plugin": "^5.29.0",
62+
"@typescript-eslint/parser": "^5.29.0",
6363
"@vitejs/plugin-vue": "^2.3.3",
64-
"@vitest/ui": "^0.15.1",
64+
"@vitest/ui": "^0.16.0",
6565
"@vue/test-utils": "2.0.1",
6666
"@vue3-oop/plugin-vue-jsx": "^1.4.0",
67-
"ant-design-vue": "^3.2.7",
67+
"ant-design-vue": "^3.2.9",
6868
"autobind-decorator": "^2.4.0",
6969
"c8": "^7.11.3",
70-
"eslint": "^8.17.0",
70+
"eslint": "^8.18.0",
7171
"eslint-config-prettier": "^8.5.0",
7272
"eslint-plugin-prettier": "^4.0.0",
73-
"happy-dom": "^5.3.1",
73+
"happy-dom": "^5.3.2",
7474
"injection-js": "^2.4.0",
75-
"lint-staged": "^13.0.2",
75+
"lint-staged": "^13.0.3",
7676
"lodash-es": "^4.17.21",
7777
"prettier": "^2.7.1",
78-
"release-it": "^15.0.0",
78+
"release-it": "^15.1.0",
7979
"rimraf": "^3.0.2",
80-
"sass": "^1.52.3",
80+
"sass": "^1.53.0",
8181
"tslib": "^2.4.0",
82-
"typescript": "^4.7.3",
82+
"typescript": "^4.7.4",
8383
"vite": "^2.9.12",
8484
"vite-plugin-dts": "^1.2.0",
8585
"vite-tsconfig-paths": "^3.5.0",
86-
"vitepress": "1.0.0-alpha.2",
87-
"vitest": "^0.15.1",
86+
"vitepress": "1.0.0-alpha.4",
87+
"vitest": "^0.16.0",
8888
"vue": "^3.2.37",
8989
"vue-router": "^4.0.16"
9090
},

0 commit comments

Comments
 (0)