Vue is not defined

使用vue+webpack开发了一个项目

在浏览器控制台访问Vue时直接抛出Vue is not defined

// main.js
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app-box')

请问如何在外部访问vue实例?

阅读 5k
4 个回答

在 created 里设置一个 window.xxx = this;

var app = new Vue()

这样不就行了?

window.app = new vue({});
这样 你可以在控制台打印app

新手上路,请多包涵

new Vue({
router,
store,
el: '#app',
components: { App },
template: '<App/>'
});

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题