store.watch
Closed this issue · 2 comments
cloook commented
store.watch(
(state) => state.sessions,
(val) => {
console.log('CHANGE: ', val);
localStorage.setItem('vue-chat-session', JSON.stringify(val));
},
{
deep: true
}
);
这里的(val)=>指的是什么呢
Coffcer commented
这是ES6写法,指代function(val){}
HiKWang commented
val
指的是state.sessions
.
store.watch
是用来监听第一个函数的返回值的,第二个函数接受的参数val
就是第一个参数的返回值state.sessins
.