Skip to content

Commit 3301210

Browse files
committed
update
1 parent 0da9af9 commit 3301210

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/store/store.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,20 @@ export default new Vuex.Store({
99
count: 0,
1010
user: {
1111
id: 'admin',
12-
log:'我是初始状态, 请点击切换按钮'
12+
log:'我是初始状态state.user.log , 请点击切换按钮'
1313
},
14+
log:'初始化我是初始状态state.log , 请点击切换按钮',
1415
},
1516
mutations: {
1617
login(state, action){
18+
state.log=true;
1719
state.user = {
1820
id:'admin',
1921
log:true
2022
};
2123
},
2224
logout(state){
25+
state.log=false;
2326
state.user = {
2427
id:'admin',
2528
log:false

src/views/admin/App.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<router-view></router-view>
55
<div style='border:2px solid;margin:20px;padding:20px'>
66
<h3>登陆状态:{{isLogin}}</h3>
7+
<h3>登陆状态:{{isLogin2}}</h3>
78
<button @click="login">切换状态</button>
89
</div>
910

@@ -20,12 +21,15 @@
2021
},
2122
computed: {
2223
isLogin: function () {
24+
return this.$store.state.log;
25+
},
26+
isLogin2: function () {
2327
return this.$store.state.user.log;
2428
}
2529
},
2630
methods:{
2731
login:function () {
28-
let state=this.$store.state.user.log;
32+
let state=this.$store.state.log;
2933
if(state){
3034
this.$store.commit('logout');
3135
}else{

0 commit comments

Comments
 (0)