-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
56 lines (49 loc) · 1.95 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script>
// 备忘录中记录内容的初始状态
let initialState = {
nextNoteId: 1,
notes: {}
}
</script>
<script src="./actions.js"></script>
<script src="./store.js"></script>
<script src="./reducer.js"></script>
<script>
// =====测试:模拟用户1的备忘录=====
const store1 = createStore(reducer);
let msgSubscriber1 = store1.subscribe(() => {
console.log('亲爱的用户1,你的备忘录更新啦!');
});
store1.dispatch(create_action);
console.log('newState====>' + JSON.stringify(store1.getState()));
// 更新一条备忘录,这里的reducer相当于就是dispatcher
// index.html(view)--->reducer(dispatch)---->update_action(action)---->changeState
store1.dispatch(update_action);
console.log('updateState====>' + JSON.stringify(store1.getState()));
</script>
<script>
// =====测试:模拟用户2的备忘录=====
const store2 = createStore(reducer);
let msgSubscriber2 = store2.subscribe(() => {
console.log('亲爱的用户2,你的备忘录更新啦!');
});
store2.dispatch(create_action);
console.log('newState====>' + JSON.stringify(store2.getState()));
// 更新一条备忘录,这里的reducer相当于就是dispatcher
// index.html(view)--->reducer(dispatch)---->update_action(action)---->changeState
store2.dispatch(update_action);
console.log('updateState====>' + JSON.stringify(store2.getState()));
store2.dispatch(update_action);
console.log('updateState====>' + JSON.stringify(store2.getState()));
</script>
</body>
</html>