2017-08-10 34 views
0

的ECMAScript 6 - 不是對象錯誤構造

enter image description here

我開始突然得到這個錯誤。我正在使用webpack和babel。 在我的存儲類中一切都很好。

我使用storege類這樣

import Storage from './storage' 

let DB = new Storage(); 

我沒有更新的巴別塔。我不知道webpack的錯誤來源?

  • 「巴別核」: 「^ 6.25.0」
  • 「巴別裝載機」: 「^ 7.1.1」
  • 「巴別預置-ES2015」: 「^ 6.24.1」
  • 「的WebPack」: 「^ 3.3.0」

我storage.js這個樣子

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)); 
}} 
+0

您是否[更新Babel](https://stackoverflow.com/q/33505992/1048572)「最近」? 「./ storage.js」是什麼樣子的,以及之前它是什麼樣的? – Bergi

+0

也請包括'storage.js',或者至少包含相關的出口。 – Scimonster

+0

./storage的外觀如何?你有默認的出口嗎? – euvl

回答

1

嘗試:

import { Storage } from './storage' 

let DB = new Storage(); 

存儲可能不是storage.js文件的默認導出。