[英]Getting Uncaught TypeError: …default is not a constructor - from Vue component
Hi I get following error in chrome console: 嗨我在chrome控制台中遇到以下错误:
Uncaught TypeError: _firebase2.default is not a constructor
when I use following code in Fire.vue (webpack vue-loader) component: 当我在Fire.vue (webpack vue-loader)组件中使用以下代码时:
var db = new Firebase(this.rootUrl)
Here is the full code of my Fire.vue : 这是我的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>
It has nothing to do with my rootUrl
property, it's just to keep the code clean. 它与我的
rootUrl
属性无关,只是为了保持代码干净。 I'm not sure if that is caused by error in Firebase package or did i miss something when importing it for my component. 我不确定这是由Firebase软件包中的错误引起的,还是在导入我的组件时错过了什么。
is not a constructor
means Firebase
object should not be called with new
keyword. is not a constructor
意味着不应使用new
关键字调用Firebase
对象。
A quick glance at the npm module page gives the following example of Fireabse initialization: 快速浏览一下npm模块页面,给出了以下Fireabse初始化示例:
var firebase = require('firebase');
var app = firebase.intializeApp({ ... });
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.