1
- import { VueComponent } from '@/extends/component'
2
- import { Component } from '@/di'
1
+ import { Component , VueComponent } from '@/index'
3
2
import { UserService } from './user.service'
4
3
import { Button , Col , Form , Input , Row } from 'ant-design-vue'
5
4
import { Ref } from '@/decorators/ref'
6
5
import { CatchLoading } from '../../common/decorators/catch.decorator'
7
6
import { Autobind } from '@/helper'
7
+ import { CountService } from '../../count.service'
8
+ import { SkipSelf } from 'injection-js'
8
9
9
- @Component ( )
10
+ @Component ( {
11
+ providers : [ CountService ] ,
12
+ } )
10
13
export default class LoginView extends VueComponent {
11
- constructor ( private userService : UserService ) {
14
+ constructor (
15
+ private userService : UserService ,
16
+ @SkipSelf ( ) private parentCountService : CountService ,
17
+ private countService : CountService ,
18
+ ) {
12
19
super ( )
13
20
}
14
21
@Ref ( ) loading = false
@@ -31,6 +38,20 @@ export default class LoginView extends VueComponent {
31
38
return (
32
39
< Row type = { 'flex' } justify = { 'center' } align = { 'middle' } style = { { height : '80%' } } >
33
40
< Col span = { 12 } >
41
+ < h3 style = { { textAlign : 'center' } } > 全局的状态: { this . parentCountService . count } </ h3 >
42
+ < h3 style = { { textAlign : 'center' } } > 局部的状态</ h3 >
43
+ < Row justify = { 'center' } >
44
+ < Col >
45
+ < Button type = { 'primary' } onClick = { this . countService . add } >
46
+ 加
47
+ </ Button >
48
+ < span style = { { fontSize : '24px' , margin : '0 20px' } } > { this . countService . count } </ span >
49
+ < Button type = { 'primary' } danger onClick = { this . countService . remove } >
50
+ 减
51
+ </ Button >
52
+ </ Col >
53
+ </ Row >
54
+ < br />
34
55
< Form labelCol = { { span : 6 } } model = { this . model } rules = { this . rules } onFinish = { this . submit } >
35
56
< Form . Item label = { '用户名' } name = { 'name' } >
36
57
< Input v-model = { [ this . model . name , 'value' ] } > </ Input >
0 commit comments