3
3
* @Date : 2022-10-20 23:54:34
4
4
* @Description : Coding something
5
5
*/
6
- import { button , div , input , style , click , $ } from '../alins' ;
6
+ import {
7
+ button , div , input , style , click ,
8
+ $ , value , IReactItem , IReactWrap
9
+ } from '../alins' ;
10
+
11
+ interface IItem {
12
+ content : string ,
13
+ done : boolean ,
14
+ }
7
15
8
16
export function todoList ( ) {
9
17
const edit = $ ( '' ) ;
10
- const list = $ ( [ ] ) ;
18
+ const list = $ < IItem [ ] > ( [ ] ) ;
11
19
const addItem = ( ) => {
12
20
list . push ( { content : edit . value , done : false } ) ;
13
21
edit . value = '' ;
14
22
} ;
15
- const removeItem = ( index ) => { list . splice ( index . value , 1 ) ; } ;
16
- const finishItem = ( item ) => { item . done = ! item . done . value ; } ;
23
+ const removeItem = ( index : IReactItem < number > ) => { list . splice ( index . value , 1 ) ; } ;
24
+ const finishItem = ( item : IReactWrap < IItem > ) => { item . done = ! item . done . value ; } ;
25
+ const clear = ( ) => { list [ value ] = [ ] ; } ;
17
26
18
- const itemStyle = ( item ) => {
27
+ const itemStyle = ( item : IReactWrap < IItem > ) => {
19
28
return style . textDecoration ( ( ) => {
20
- debugger ;
21
29
return item . done . value ? 'line-through' : 'none' ;
22
30
} )
23
31
. color ( ( ) => item . done . value ? '#888' : '#222' ) ;
@@ -37,6 +45,7 @@ export function todoList () {
37
45
) ,
38
46
] ) ,
39
47
) ,
48
+ button ( 'clear' , click ( clear ) ) ,
40
49
] ;
41
50
}
42
51
// // function a (x) {
0 commit comments