如何使用/// <reference path =“”... =“”>标签将localForage导入到Typescript项目?

时间:2017-06-19 06:21:10

标签: typescript webstorm localforage

我在Typescript中有一个项目,我想使用依赖&#34; localForage&#34;:https://github.com/localForage/localForage

我通过以下npm命令安装它:

  

npm install @ types / localforage --save

我用过:

/// <reference path="typings/index.d.ts" />
///<reference path="node_modules/localforage/typings/localforage.d.ts"/>

import lf = require("./node_modules/localforage");

lf.setItem("blabla", "blabla");
lf.getItem("blabla", (err, data) => {
    console.log(data);
})

当我在浏览器中运行它时,我收到错误:

  

未捕获错误:无法找到模块&#34; localforage&#34;来自&#34; undefined&#34;

我使用此链接来解决此问题:https://www.tomsdev.com/blog/2015/packaging-typescript-module-publish-npm-release/

0 个答案:

没有答案