【发布时间】:2017-05-23 17:02:58
【问题描述】:
我正在尝试使用位于
的 localstorage NativeScript 模块https://www.npmjs.com/package/nativescript-localstorage
我有一个从 Web 应用程序复制的 LocalStorage 服务,我想与 NativeScript 应用程序一起使用,我使用 tns 插件添加 nativescript-localstorage 成功安装了模块。我感到困惑的第一件事是:我的应用程序是用 Typescript 编写的,而这个模块是用 Javascript 编写的,我可以在我的应用程序中导入/使用这个模块吗?我在 LocalStorageService 的导入部分添加了以下内容: var localStorage = require('nativescript-localstorage');该应用程序构建良好,但部署后出现以下错误:
错误: 错误:com.tns.NativeScriptException:找不到模块:“nativescript-localstorage”,相对于:app/tns_modules/
然后我尝试: import * as localStorage from 'nativescript-localstorage';然后我收到一条错误消息,说找不到模块 nativescript-localstorage。知道我做错了什么吗?
【问题讨论】:
标签: angular angular2-nativescript