Javascript 无法读取属性';默认值';未定义的
在下面的Javascript 无法读取属性';默认值';未定义的,javascript,react-native,realm,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, Configurat
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() {..};
错误
尝试删除“默认”关键字,它将正常工作
export function Db() {
this.realm = new Realm({
schema: [Wallet, WalletAddress, WalletTransaction, Log, APIWallet, APITransaction, APIAccount, Configuration],
path: config.db_path
});
logger(2, realm.path);}
试试这个…不起作用。抛出一个新错误
\u Db2.default不是构造函数。