react-native – 域错误 – _constructor必须是’function’类型
发布时间:2020-12-15 20:49:05 所属栏目:百科 来源:网络整理
导读:我正在尝试使用我的本机应用程序本地设置Realm DB,但似乎有一个错误,我无法找出原因.我遵循了 documentation和指南 here. 我的代码. import Realm from 'realm';export const ConfigSchema = { name: 'Config',primaryKey: 'key',properties: { key: 'string
我正在尝试使用我的本机应用程序本地设置Realm DB,但似乎有一个错误,我无法找出原因.我遵循了
documentation和指南
here.
我的代码. 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 <anonymous> (MetroClient.js:63),<anonymous>:29:22) at tryCallTwo (core.js:45) at doResolve (core.js:200) at new Promise (core.js:66) at insertNewConfig (eval at <anonymous> (MetroClient.js:63),<anonymous>:28:12) at Object.SelectInstanceScreen._this.continueLogin [as onPress] (eval at <anonymous> (MetroClient.js:63),<anonymous>:74:37) 似乎open()函数必须作为函数调用(_constructor必须是’function’类型),但很明显open()作为函数调用.
我想也许是最后一个版本(2.18.0)上的一个错误,尝试降级到2.16.0它会起作用.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |