热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

领域错误-_constructor必须是'function'类型,得到(undefined)

如何解决《领域错误-_constructor必须是'function'类型,得到(undefined)》经验,为你挑选了1个好方法。

我正在尝试使用我的本机应用程序在本地设置Realm DB,但似乎有一个错误,我无法找出原因.我在这里遵循了文档和指南.

我的守则.

import Realm from 'realm';

export const COnfigSchema= {
    name: 'Config',
    primaryKey: 'key',
    properties: {
        key: 'string',
        value: 'string'
    }
};

export const databaseOptiOns= {
    path: 'myappreactnative.realm',
    schema: [ConfigSchema],
    schemaVersion: 0
};

export const insertNewCOnfig= (newConfig) => new Promise((resolve, reject) => {
    Realm.open(databaseOptions).then(realm => {
        // realm.create('Config', newConfig);
        // resolve(newConfig);
        console.log(realm);
    }).catch((error) => reject(error))
});

我在insertNewConfig这里打电话,

let cOnfig= {
    key: 'instanceUrl',
    value: 'myurl.domain.value'
};

insertNewConfig(config).then((result) => {
    console.log(result);
}).catch((error) => {
    console.log(error);
});

this.props.navigation.navigate('Login', {});

错误就在那里Realm.open(databaseOptions).首先,我虽然错误与realm.create但后来实现了原始线.

显示的错误是这样的.

Error: _constructor must be of type 'function', got (undefined)
    at sendRequest (rpc.js:263)
    at Object.createRealm (rpc.js:62)
    at new Realm (index.js:102)
    at Function.open (extensions.js:110)
    at eval (eval at  (MetroClient.js:63), :29:22)
    at tryCallTwo (core.js:45)
    at doResolve (core.js:200)
    at new Promise (core.js:66)
    at insertNewConfig (eval at  (MetroClient.js:63), :28:12)
    at Object.SelectInstanceScreen._this.continueLogin [as onPress] (eval at  (MetroClient.js:63), :74:37)

似乎open()函数必须作为函数调用(_constructor必须是'function'类型),但很明显它open()被称为函数.提前致谢.



1> C-lio Garcia..:

我想也许是最后一个版本(2.18.0)上的一个错误,尝试降级到2.16.0它会起作用.


推荐阅读
author-avatar
蓝色春天绿意长
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有