入门TypeError:...默认不是构造函数-来自Vue组件 [英] Getting Uncaught TypeError: ...default is not a constructor - from Vue component

查看:157
本文介绍了入门TypeError:...默认不是构造函数-来自Vue组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Chrome控制台中收到以下错误:

Hi I get following error in chrome console:

Uncaught TypeError: _firebase2.default is not a constructor

当我在 Fire.vue (Webpack vue-loader)组件中使用以下代码时:

when I use following code in Fire.vue (webpack vue-loader) component:

var db = new Firebase(this.rootUrl)

这是我的 Fire.vue 的完整代码:

<template lang="jade">
  h2 Hello from: {{ component_name }}
</template>

<script>
import Vue from 'vue'
import Firebase from 'firebase'
Vue.prototype.$consoleLog = function (args) { console.log(args) }

export default {
  props: {
    rootUrl: {
      default: 'https://boiling-heat...', // here will be url of database
      type: String
    }
  },
  data () {
    return {
      component_name: 'Firebase component!'
    }
  },
  ready () {
    var db = new Firebase(this.rootUrl) // <- this causes error
    this.$consoleLog(db)
  }
}
</script>

它与我的 rootUrl 属性无关,只是为了保持代码的清洁.我不确定这是由Firebase软件包中的错误引起的,还是在为我的组件导入它时错过了某些东西.

It has nothing to do with my rootUrl property, it's just to keep the code clean. I'm not sure if that is caused by error in Firebase package or did i miss something when importing it for my component.

推荐答案

不是构造函数表示不应使用 new Firebase 对象>关键字.

is not a constructor means Firebase object should not be called with new keyword.

快速浏览 npm模块页面,可以看到以下Fireabse初始化示例:

A quick glance at the npm module page gives the following example of Fireabse initialization:

var firebase = require('firebase');
var app = firebase.intializeApp({ ... });

这篇关于入门TypeError:...默认不是构造函数-来自Vue组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆