//设置环境
const target =typeof window !== "undefined"? window: typeof global !== "undefined"? global: {
};//用于判断是否使用了开发者工具 devtool
const devtoolHook = target.__VUE_DEVTOOLS_GLOBAL_HOOK__;export default function devtoolPlugin(store) {
//如果没有安装,直接退出。if (!devtoolHook) return;//如果安装了,则设置到 store 上。store._devtoolHook = devtoolHook;//store 的 constructor() 函数调用时, 会调用 devtoolPlugin 函数。所以是处于vuex的init状态。devtoolHook.emit("vuex:init", store);//没弄懂是要监听啥?devtoolHook.on("vuex:travel-to-state", (targetState) => {
store.replaceState(targetState);});/*定于 store 的 mutation。会被添加到 store._subscribers[] 中。*/store.subscribe((mutation, state) => {
devtoolHook.emit("vuex:mutation", mutation, state);},{
prepend: true });/**订阅 store 的 action。会被添加到 store._subscribeAction[] 中。*/store.subscribeAction((action, state) => {
devtoolHook.emit("vuex:action", action, state);},{
prepend: true });
}
详细解决方案
vuex3源码注释 /res/plugins/devtool.js
热度:91 发布时间:2023-10-26 11:46:23.0
相关解决方案
- Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:该怎么处理
- Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:该如何解决
- Wordpress图片相本插件/ Gallery Plugins
- 关于支付宝控件 关于navigator.plugins,该怎么处理
- jQuery插件写法入门图书(Plugins/Authoring)
- Eclipse 惯用 plugins 插件
- MyEclipse9 破译 找不到Common\plugins\com.genuitec.eclipse.core_9.0.0.me201103181703.jar
- ADT for exlipse plugins 就要过时了
- idea的Maven配置问题:Cannot resolve plugin org.apache.maven.plugins:maven-clean-plugin:2.5
- nagios监控mysql(percona-monitoring-plugins)
- 编译安装nagios-4.3.2+plugins-2.2.1+check_mysql
- maven报错之--Plugin org.apache.maven.plugins:maven-clean-plugin:2.6....peer not authenticated
- webpack 中配置 devtool 的作用
- react+webpack项目常用的插件(plugins)
- Loaded plugins: fastestmirror, security file: file:///etc/yum.repos.d/6CentOS-Base.repo, line: 1
- 使用IDEA误配置Kotlin后项目报红,cannot resolve plugin org.apache.maven.plugins:<unknow>
- 使用yum安装wget时报出:Loaded plugins: fastestmirror No such command: instal. Please use /usr/bin/yum --help
- vuex3源码注释系列 /src/plugins/logger.js
- vuex3源码注释 /res/plugins/devtool.js
- vuex3.0源码注释系列 /src/mixin.js
- vuex3.0源码注释系列 vuex入口文件/src/index.js
- [ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-war) on pr
- 100%帮你解决,关于maven项目报:org.apache.maven.plugins:maven-resources-plugin:2.6的解决办法,
- Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.1.0 报错
- maven 执行clean package后报错:Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.7
- 关于解决RedHat7.0 yum命令出现:Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
- Failure to transfer org.apache.maven.plugins:maven-surefire-plugin:pom:2.18.1 from ...
- [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources
- Could not write metadata for '/RemoteSystemsTempFiles'. D:\workspace\.metadata\.plugins\org.eclipse.
- 关于解决RedHat6.0以上版本:Loaded plugins: product-id, refresh-packagekit, security, subscription-manager