angular - 找不到模块 'application-settings'

标签 angular typescript nativescript

尝试包含“应用程序设置模块”时出现错误。

*找不到模块“应用程序设置”<-----错误

错误出现在我的 storage.driver.ts 中,它位于使用 loopback sdk builder 构建的 nativescript sdk 中

存储驱动程序.ts

import * as AppSettings from 'application-settings'; <---- Error here
export class StorageDriver {
static set(key: string, value: any) {
AppSettings.setString(key, String(value));
}
static get(key: string): any {
return AppSettings.getString(key);
}
static remove(key: string): any {
if (AppSettings.hasKey(key)) {
  AppSettings.remove(key);
} else {
  console.log('Trying to remove unexisting key: ', key);
}
}
}
  • https://github.com/m-expert-official/loopback-sdk-builder/wikiean

  • 我应该怎么做才能解决这个问题?我是 nativescript 的新手。

    最佳答案

    'application-settings' 已移至 'tns-core-modules',现在已弃用为 'application-settings',其他核心 nativescript 模块现在是 '@nativescript/core' 的一部分。
    现在我们使用“@nativescript/core”而不是“tns-core-modules”。

    @不推荐使用

    import * as AppSettings from 'tns-core-modules/application-settings';
    

    改用这个:
    import * as AppSettings from '@nativescript/core/application-settings';
    

    关于angular - 找不到模块 'application-settings',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41032988/

    相关文章:

    javascript - 在 S3 存储桶上的 Angular 2/4 应用程序中允许 CORS 传入请求还需要什么

    javascript - 在服务方法中查询列表并将结果返回给组件?

    JavaScript:保存实体,可以写得更好吗?

    NativeScript 处理后退按钮事件

    angular - 如何使 Angular 模块忽略核心模块中添加的http拦截器

    javascript - 在 ionic 页面中返回 Promise.reject

    javascript - 如果所有子组件都被隐藏,如何隐藏组件 ngIf

    javascript - 使用 TypeScript 检查 Immutable.js Record.set 类型

    ios - 如何设置 RadDataForm ListPicker 的选择器的样式

    javascript - 在 native 脚本 ListView 中获取录制的项目上下文或索引