React Native开发React Native实践React Native开发经验集

React-native Unable to open a re

2019-04-01  本文已影响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();
}
上一篇下一篇

猜你喜欢

热点阅读