Skip to content

Commit 2c5e942

Browse files
committed
feat: 导出 IReactObject IComputedItem IReactWrap
1 parent 89d3753 commit 2c5e942

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

packages/core/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ export {
2828
react, computed, watch, createProxy, $,
2929
} from 'alins-reactive';
3030

31-
export {IReactItem} from 'alins-utils/src/types/react.d';
31+
export {IReactItem, IReactObject, IReactWrap, IComputedItem} from 'alins-utils/src/types/react.d';
3232

3333
export {version} from '../package.json';

scripts/dev/samples/todo-list.ts

+15-6
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,29 @@
33
* @Date: 2022-10-20 23:54:34
44
* @Description: Coding something
55
*/
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+
}
715

816
export function todoList () {
917
const edit = $('');
10-
const list = $([]);
18+
const list = $<IItem[]>([]);
1119
const addItem = () => {
1220
list.push({content: edit.value, done: false});
1321
edit.value = '';
1422
};
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] = []; };
1726

18-
const itemStyle = (item) => {
27+
const itemStyle = (item: IReactWrap<IItem>) => {
1928
return style.textDecoration(() => {
20-
debugger;
2129
return item.done.value ? 'line-through' : 'none';
2230
})
2331
.color(() => item.done.value ? '#888' : '#222');
@@ -37,6 +45,7 @@ export function todoList () {
3745
),
3846
]),
3947
),
48+
button('clear', click(clear)),
4049
];
4150
}
4251
// // function a (x) {

0 commit comments

Comments
 (0)