反应本机,我正在尝试打开数据库。首先,我创建的数据库名称为“ exampledb.db”。我同时添加了“ react-native-sqlite-storage”和“ react-native-sqlite3”,两者均已安装并已链接。但我的代码无法正常工作。 我遵循的是此链接https://github.com/andpor/react-native-sqlite-storage中的说明 这是我的代码和错误图片,请检查
import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View} from 'react-native';
import SQLite from 'react-native-sqlite-storage';
const instructions = Platform.select({
ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu',
android:
'Double tap R on your keyboard to reload,\n' +
'Shake or press menu button for dev menu',
});
type Props = {};
//var React = require('react-native');
//var SQLite = require('react-native-sqlite-storage')
export default class App extends Component<Props> {
constructor(props) {
super(props)
this.openCB = this.openCB.bind(this);
this.errorCB = this.errorCB.bind(this);
}
errorCB(err) {
console.log("SQL Error: " + err);
}
successCB() {
console.log("SQL executed fine");
}
openCB() {
console.log("Database OPENED");
}
componentWillMount() {
var db = SQLite.openDatabase("exampledb.db", "1.0", "Test Database", 200000, this.openCB, this.errorCB);
}