React-native Unable to open a re

作者: _海角_ | 来源:发表于2019-04-01 14:03 被阅读3次

    接上一篇
    React-native Realm 数据迁移

    iOS端 没有异常,Android端出现了 Unable to open a realm at path '.management'.的错误
    在stackoverflow中查找,

    let nextSchemaIndex = Realm.schemaVersion(Realm.defaultPath);
    while (nextSchemaIndex < schemas.length) {
      const migratedRealm = new Realm(schemas[nextSchemaIndex]);
      nextSchemaIndex += 1;
      migratedRealm.close();
    }
    

    更换代码为下面,android端口则可正常。

    let nextSchemaIndex = Realm.schemaVersion(Realm.defaultPath);
    while (nextSchemaIndex < schemas.length) {
      const migratedRealm = new Realm({ ...schemas[nextSchemaIndex] });
      nextSchemaIndex += 1;
      migratedRealm.close();
    }
    

    相关文章

      网友评论

        本文标题:React-native Unable to open a re

        本文链接:https://www.haomeiwen.com/subject/mvhvbqtx.html