解决办法:如果发布消息的组件中使用的代码形如this.PubSub.publish(‘xxx’, test),就将其中的this.去掉,即直接使用PubSub.publish(‘xxx’, test)。
在vue中进行组件间通信时,发现控制台出现如下异常:
[Vue warn]:Error in callback for watcher "xxx": "TypeError: Cannot read property 'publish' of undefined"
经过网上反复查询,未找到有用信息
将this.PubSub.publish(‘xxx’, xxx)中的this.去掉
居然成功了,究其原因,尚不明确。