无法读取undefined的属性'default'

时间:2018-03-30 17:10:35

标签: javascript react-native realm

在下面的this.realm =行中获取此错误。不确定为什么这个代码在格式化为工厂函数时有效

import Realm from 'realm';

export default function Db() {
    this.realm = new Realm({
        schema: [Wallet, WalletAddress, WalletTransaction, Log, APIWallet, APITransaction, APIAccount, Configuration],
        path: config.db_path
    });
    logger(2, realm.path);
}

Db.prototype.doOneToMany = function(one, many) {..};

Db.prototype.query = function(model, filter) {..};

Db.prototype.insert = function(model, options) {..};

Db.prototype.del = function(model, obj) {..};

Db.prototype.update = function(obj, options) {..};

Db.prototype.write = function(func) {..};

Db.prototype.close = function() {..};

错误

enter image description here

1 个答案:

答案 0 :(得分:-1)

尝试删除“默认”关键字,它会正常工作......

export function Db() {
this.realm = new Realm({
    schema: [Wallet, WalletAddress, WalletTransaction, Log, APIWallet, APITransaction, APIAccount, Configuration],
    path: config.db_path
});
logger(2, realm.path);}

试试这个......