Vuex之严格模式

仅需在创建store时传入strict:true

const store= new Vuex.Store({
 strict:true
})

严格模式下,不是有mutation函数引起的状态变化都会抛出错误。这保证了状态变更都能被调试工具跟踪到。
不要再发布环境下启用严格模式,严格模式会深度监测状态树来检测不合规的状态变化,请确保发布环境下关闭严格模式,以避免性能损失。

类似于插件,我们可以让构建工具来处理;

const store= new Vuex.Store({
 strict:process.env.NODE_ENV !=='production'
})

猜你喜欢

转载自blog.csdn.net/e_li_na/article/details/80264230
今日推荐