... is not a constructor
发布于 6 年前 作者 yong73 10140 次浏览 来自 问答

写了一个ES6的类,不勾选ES6转ES5的时候显示 Unexpected export module,勾选后显示 … is not a constructor,请问是什么原因呢?


class MDb {
  constructor(){
    this.storageKeyName = 'Odata';
  }
 
  // 获取所有数据
  getAllOdata(){
    var res = wx.getStorageSync(this.storageKeyName);
    if(!res){
      res = require('../data/data.js').Odata;
      this.execSetStorageSync(res);
    }
    return res;
  }
 
  // 保存或更新缓存数据
  execSetStorageSync(data){
    wx.setStorageSync(this.storageKeyName, data);
  }
};
 

export { MDb }


2 回复

什么变量名?

啊 原来变量名和es6类名不能重复。。。

回到顶部