小编Yit*_*lub的帖子

类型错误:未定义不是一个对象(评估'_expo.default.FileSystem')]

我正在尝试将数据库文件从资产导入博览会。但它只是不起作用并返回给我以下警告:

类型错误:未定义不是一个对象(评估'_expo.default.FileSystem')]

我尝试了很多次,如果我创建一个新数据库它可以工作,但是如果我尝试从资产加载现有数据库它将无法工作

class Items extends React.Component {
  state = {
    items: null
  };

  componentDidMount = async () => {
    await Expo.FileSystem.downloadAsync(
      Expo.Asset.fromModule(require("./assets/exu-word.db")).uri,
      `${Expo.FileSystem.documentDirectory}SQLite/exu-word.db`
    );

    let db1 = SQLite.openDatabase("exu-word.db");
  };

  render() {

    const { items } = this.state;


    if (items === null || items.length === 0) {
      return null;
    }

    return (
      <View style={styles.sectionContainer}>

        {items.map(({ id, words }) => (
          <TouchableOpacity
            key={id}
            onPress={() => this.props.onPressItem && this.props.onPressItem(id)}
            style={{
              backgroundColor: "#fff",
              borderColor: "#000",
              borderWidth: 1,
              padding: 8
            }}
          >
            <Text style={{ …
Run Code Online (Sandbox Code Playgroud)

react-native expo

3
推荐指数
1
解决办法
2792
查看次数

标签 统计

expo ×1

react-native ×1