Monday, 15 May 2017

Imported Class Constructor Undefined on Babel(ES6)

I'm a newbie and making a simple code testing Babel ES6, Webpack, Vue.

However, I'm facing a problem with importing Class.

project_folder/src/index.js

import { Octopus } from './view/A.vue';

console.log(Octopus);
const a = new Octopus();
console.log(a);

project_folder/src/view/A.vue

import Vue from 'vue';

export class Octopus {
    constructor () {
        console.log("Hello");
    }
}

The webpack and lint seems ok.

But on logging the "Octopus" on console, prints an undefined, and prints error that Octopus is not a constructor.

Thanks.



via Sung Jae Cho

No comments:

Post a Comment