最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Getting Uncaught TypeError: ...default is not a constructor - from Vue component - Stack Overflow

programmeradmin0浏览0评论

Hi I get following error in chrome console:

Uncaught TypeError: _firebase2.default is not a constructor

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

var db = new Firebase(this.rootUrl)

Here is the full code of my Fire.vue:

<template lang="jade">
  h2 Hello from: {{ ponent_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 {
      ponent_name: 'Firebase ponent!'
    }
  },
  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. I'm not sure if that is caused by error in Firebase package or did i miss something when importing it for my ponent.

Hi I get following error in chrome console:

Uncaught TypeError: _firebase2.default is not a constructor

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

var db = new Firebase(this.rootUrl)

Here is the full code of my Fire.vue:

<template lang="jade">
  h2 Hello from: {{ ponent_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 {
      ponent_name: 'Firebase ponent!'
    }
  },
  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. I'm not sure if that is caused by error in Firebase package or did i miss something when importing it for my ponent.

Share Improve this question asked May 21, 2016 at 8:28 Dariusz SikorskiDariusz Sikorski 4,4075 gold badges30 silver badges44 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

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

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

var firebase = require('firebase');
var app = firebase.intializeApp({ ... });
发布评论

评论列表(0)

  1. 暂无评论