小编Chr*_*ian的帖子

nativescript-sqlite和angular2模块未找到异常

我有一个带有angular2应用程序的nativescript for android,我想利用nativescript-sqlite的离线存储功能.问题是我得到以下异常:

Failed to find module: "nativescript-sqlite", relative to: /app/tns_modules/
Run Code Online (Sandbox Code Playgroud)

在下面的行:

var Sqlite = require("nativescript-sqlite");
Run Code Online (Sandbox Code Playgroud)

我使用以下命令安装插件

tns插件添加nativescript-sqlite

我创建了一个带有角度服务的db.service.ts文件,其内容如下:

import {Injectable} from "@angular/core";
import {Config} from "../config";
import {Observable} from "rxjs/Rx";
import "rxjs/add/operator/do";
import "rxjs/add/operator/map";

import {Profile} from "../profile/profile";

var Sqlite = require("nativescript-sqlite");

@Injectable()
export class DbService {
    database: any;

    constructor() {
        (new Sqlite("gtel.db")).then(db => {
            this.database = db;
            db.resultType(Sqlite.RESULTSASOBJECT);
            this.database.execSQL("CREATE TABLE IF NOT EXISTS profile (id INTEGER PRIMARY KEY AUTOINCREMENT," +
                " username TEXT, idnumber TEXT, firstname TEXT, lastname …
Run Code Online (Sandbox Code Playgroud)

sqlite android angularjs nativescript angular

5
推荐指数
1
解决办法
747
查看次数

标签 统计

android ×1

angular ×1

angularjs ×1

nativescript ×1

sqlite ×1