错误未捕获的SyntaxError:离子2中的意外令牌导入

时间:2016-07-14 05:57:02

标签: javascript import angular ionic2

我知道这个问题已经问到了,但是没有任何解决方案,所以我再次提出了这个问题

我希望在混合应用程序中本地存储数据,因此我使用了SqlStorage数据库。在平台就绪事件中,我试图插入dumy数据。

当我在Chrome控制台中评估我的代码时出现错误。 未捕获的SyntaxError:意外的令牌导入

我用的代码

import {Component} from '@angular/core';
import {Platform, ionicBootstrap} from 'ionic-angular';
import {LoginTabPage} from './pages/login-tab/login-tab';
import {enableProdMode} from '@angular/core';
import {WebService} from './services/webservice';
import {StatusBar} from 'ionic-native';
import {DatabaseHelper} from './services/DatabaseHelper';
import {Storage, SqlStorage} from 'ionic-angular';

@Component({
  template: '<ion-nav [root]="rootPage"></ion-nav>'
})
export class MyApp {
  rootPage: any = LoginTabPage;
  //public db: SQLite;
  db : DatabaseHelper;
  storage: Storage = null;


  constructor(platform: Platform) {

    platform.ready().then(() => {
            StatusBar.styleDefault();
            this.db = new DatabaseHelper();
            let options = {
              name: '_Novity',              // the name of the database
              backupFlag: SqlStorage.BACKUP_LOCAL, // where to store the file
              existingDatabase: false              // load this as an existing database
            };
            this.storage = new Storage(SqlStorage, options);
                this.db.createMemberTable();
            this.db.createLoginTable();

            var sql = 'INSERT INTO ' + this.db.sqtable_UserInfo + ' ( '+this.db.COLUMN_userId +' , '+ this.db.COLUMN_password + ' ) VALUES ( ?, ?)';
            this.storage.query(sql, ['varshil','shah']).then((res) => {
                  console.log(res);
              }, (err) => {
                  console.log('Error: ', err.res);
              });
        });
  }
}
enableProdMode();
ionicBootstrap(MyApp,[WebService]);

public createLoginTable()
    {

       this.storage.query('CREATE TABLE IF NOT EXISTS '+ this.sqtable_UserInfo +' ( '+ this.COLUMN_userId +' TEXT, '+ this.COLUMN_password +' TEXT)');
    }

当我在查询中运行未定义错误的代码

0 个答案:

没有答案