Fe-interview: [vue] vuex怎么知道state是通过mutation修改还是外部直接修改的?

Created on 20 Jun 2019  ·  5Comments  ·  Source: haizlin/fe-interview

[vue] vuex怎么知道state是通过mutation修改还是外部直接修改的?

vue

Most helpful comment

通过$watch监听mutation的commit函数中_committing是否为true

All 5 comments

不知道哟, mark一下

通过$watch监听mutation的commit函数中_committing是否为true

这道题感觉有点问题,在vuex严格模式下,是不让外部直接修改state的

修改state数据,只有mutation这唯一路径

不通过mutation直接修改state浏览器会报错

Was this page helpful?
0 / 5 - 0 ratings