我想使用单独的Vue
实例来处理事件。这种方法适用于标准的Vue
应用程序,但在Nuxt
环境中引发错误。
我需要以不同的方式简单地引用它吗?
码
const Vue = require('vue');
const Hub = new Vue();
export default Hub;
// Usage
import Hub from '~/events/hub';
Hub.$emit(EVENT_TOGGLE_NAVIGATION, true);
错误
Uncaught TypeError: Vue is not a constructor
环境
nuxt 1.0.0
vue 2.5.17
您需要使用导入
import Vue from 'vue'