Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
293 views
in Technique[技术] by (71.8m points)

Nuxt.js 中如何配置eventHub?

通常我们这样在main.js中配置eventHub

export default {
  name: "App",
  data() {
    return {
      eventHub: new Vue()
    };
  },
  provide() {
    return {
      eventHub: this.eventHub
    };
  }
};

现在问题是Nuxt没有main.js 请问如何配置能达到一样的效果呢?
请大佬们解疑~ 个人基本思路是通过plugins,但是具体怎么实现呢?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

plugin里 直接Vue.prototype.$eventBus = new Vue()


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...