1
- import _Vue , { PluginObject , Component , EventType } from './interface'
1
+ import { VueType , PluginObject , Component , ComponentConfig , EventType } from './interface'
2
2
3
- class VueDynamicComponent implements PluginObject < Component > {
4
- private V : _Vue
3
+ class VueDynamicComponent implements PluginObject < Component , any > {
4
+ private V : VueType
5
5
6
- private components : Component
6
+ components : Component
7
7
8
- constructor ( ) {
8
+ constructor ( components : Component ) {
9
9
this . V = null
10
- this . components = { }
10
+ this . components = components
11
11
}
12
12
13
- public install ( Vue , components ) {
13
+ public install ( Vue : VueType ) : void {
14
14
this . V = Vue
15
- this . components = components
16
15
this . V . prototype . $bus = new Vue ( )
17
16
this . containerInit ( this . V )
18
17
this . childComponentsRegister ( )
19
18
}
20
19
21
- private containerInit ( V ) {
20
+ private containerInit ( V : VueType ) : void {
22
21
const container = {
23
22
name : 'dynamic-container' ,
24
23
data ( ) {
@@ -67,7 +66,7 @@ class VueDynamicComponent implements PluginObject<Component> {
67
66
document . body . appendChild ( instance . $el )
68
67
}
69
68
70
- private createDynamicComp ( component , { attrs, on, ...args } ) {
69
+ private createDynamicComp ( component : VueType , { attrs, on, ...args } : ComponentConfig ) : VueType {
71
70
const compInstance = this . V . extend ( component )
72
71
this . V . prototype . $bus . $emit ( EventType . APPEND , compInstance , {
73
72
attrs,
@@ -77,7 +76,7 @@ class VueDynamicComponent implements PluginObject<Component> {
77
76
return compInstance
78
77
}
79
78
80
- private deleteDynamicComp ( compInstance ) {
79
+ private deleteDynamicComp ( compInstance : VueType ) {
81
80
this . V . prototype . $bus . $emit ( EventType . REMOVE , compInstance )
82
81
}
83
82
@@ -89,7 +88,8 @@ class VueDynamicComponent implements PluginObject<Component> {
89
88
// eslint-disable-next-line @typescript-eslint/no-use-before-define
90
89
this . deleteDynamicComp ( componentInstance )
91
90
}
92
- const componentInstance = this . createDynamicComp ( this . components [ key ] , {
91
+ const instance = this . components [ key ]
92
+ const componentInstance = this . createDynamicComp ( instance , {
93
93
attrs,
94
94
on : {
95
95
'on-confirm' : data => {
0 commit comments