Native: tried accessing the SQLite plugin but it's not installed."
在Android 模拟器和真机中都无法创建sqlite 的数据库
在模拟器中提示Native: tried accessing the SQLite plugin but it's not installed."
结合初始化数据库的写法如下,造成的原因是设备未真正的就绪,sqlite的插件未加载的情况就去初始化数据库
在app.component.ts中写法如下
export class AppComponent { constructor(private sqlService: SQLService,private sqlite: SQLite,private platform: Platform, private splashScreen: SplashScreen, private statusBar: StatusBar, ) { this.sqlService.initDB(); } }
正确的写法是:使用platform的ready()来判断设备的真正就绪
export class AppComponent { constructor(private sqlService: SQLService,private sqlite: SQLite,private platform: Platform, private splashScreen: SplashScreen, private statusBar: StatusBar, ) { this.platform.ready().then(() => { this.sqlService.initDB(); }); } }
此时就能正常建立数据库