【问题标题】:Solved - error TS2350: Only a void function can be called with the 'new' keyword [closed]已解决 - 错误 TS2350:只能使用 'new' 关键字调用 void 函数 [关闭]
【发布时间】:2019-08-14 11:11:07
【问题描述】:

我正在尝试实现与我的应用程序的 SQLite 数据库连接。

我在“sqlite.service.ts”文件中使用以下代码

import { Injectable } from "@angular/core";
var Sqlite = require{"nativescript-sqlite"};

@Injectable()
export class DatabaseService {

    public getdbConnection() {
        return new Sqlite('Assets');
    }

    public closedbConnection() {
        new Sqlite('Assets')
            .then((db) => {
                db.close();
            })
    }
}

我已使用 nativescript 代码示例“使用 SQLite 的杂货应用程序”作为此代码的基础,并且可以正常运行。

谁能提供建议?

【问题讨论】:

  • 你确定你的 require path 指向 sqlite 包吗?
  • @Florian,您能否详细说明“需要路径”的含义
  • require{"nativescript-sqlite"}。你的路径是 nativescript-sqlite,你的包在哪里?你的包应该在node_modules,所以确保你指向你的node_modules目录

标签: angular sqlite nativescript


【解决方案1】:

应该是require("nativescript-sqlite") 而不是require{"nativescript-sqlite"}

【讨论】:

    猜你喜欢
    • 2019-07-21
    • 1970-01-01
    • 2017-09-15
    • 2020-02-26
    • 2021-05-04
    • 1970-01-01
    • 2015-08-21
    • 2021-08-12
    相关资源
    最近更新 更多