简体   繁体   中英

ecmascript 6 - not a constructor at Object error

在此处输入图片说明

I am began get this error suddenly. I'm using webpack and babel. in my storage class everything fine.

I'm using storege class like this

import Storage from './storage'

let DB = new Storage();

I didn't update the babel. I don't know source of error maybe webpack?

  • "babel-core": "^6.25.0"
  • "babel-loader": "^7.1.1"
  • "babel-preset-es2015": "^6.24.1"
  • "webpack": "^3.3.0"

my storage.js look like this

import localStorage from './localStorage'
import View from './view'

let lStore = new localStorage();
let V = new View();

let data = (lStore.get('todo')) ? JSON.parse(lStore.get('todo')):{
    todo: [],
    complated: []
};

export default class Storage {

addItem(text, id){
    /* Store  */
    this.store(text);

    /* Add HTML Item */
    V.addToDOM(text, id);
}

store(text){
    data.todo.push(text);
    data.complated.push(false);

    //sync
    this.objectLocalStorage();
}

list() {
    return data;
}

updateItem(id, complated){
    /* */
    data.complated[id] = complated;

    //sync
    this.objectLocalStorage();
}

deleteItem(id){
    data.complated.splice(id, 1);
    data.todo.splice(id, 1);

    //sync
    this.objectLocalStorage();
}

/* Local Storage Set-Update-Sync */
objectLocalStorage() {
    lStore.set('todo', JSON.stringify(data));
}}

Try:

import { Storage } from './storage'

let DB = new Storage();

Storage is probably not the default export of the storage.js file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM