Requirejs 带有Require.js的localfower

Requirejs 带有Require.js的localfower,requirejs,localforage,Requirejs,Localforage,我正在尝试用require.js加载lib,但无法使其工作。下面是我的require.js配置: main.html: <body> <script type="text/javascript" src="/xyz/js/lib/require-2.1.22.js"> </script> <script type="text/javascript" src="/xyz/js/main.js?version=1.0.0"></script

我正在尝试用require.js加载lib,但无法使其工作。下面是我的require.js配置:

main.html:

<body>
 <script type="text/javascript" src="/xyz/js/lib/require-2.1.22.js">  </script>
 <script type="text/javascript" src="/xyz/js/main.js?version=1.0.0"></script>
</body>
但是当我后来开始像这样使用localfough时

localforage.setDriver(localforage.INDEXEDDB).then(function() {
    console.log("Hi there");
});
它总是未定义的。顺便说一句,我也有同样的问题。 当我从自述文件中添加以下代码时

define(['localforage'], function(localforage) {
  // As a callback:
  localforage.setItem('mykey', 'myvalue', console.log);

  // With a Promise:
  localforage.setItem('mykey', 'myvalue').then(console.log);
});
我从requirejs.org/docs/errors.html获取错误#不匹配
但这意味着什么?有人能给我解释一下吗?我真的不明白。

你可以试试回购的例子,特别是。 更详细地说,完整的
main.js
文件如下所示:

requirejs.config({
路径:{
localfollow:'path/to/dist/localfollow'
}
});
定义(['localfollow'],函数(lf){
lf.ready().then(函数()){
var key='STORE_key';
var值='我们离线保存的内容';
lf.setItem(key,value).then(function(){
console.log('保存',值);
返回lf.getItem(键);
}).then(函数(readValue){
console.log('READING',readValue);
});
});

});与此同时,我似乎必须将上面的define调用从“define(['localfound'],function(localfound)”更改为“define('localfound',['localfound'],function(localfound)”。现在呼叫不再是匿名的。但“LocalFower”仍未定义!?如果其他人对我感兴趣,我已通过使用此处的解决方案使其工作,即使我没有使用缩小版本:
define(['localforage'], function(localforage) {
  // As a callback:
  localforage.setItem('mykey', 'myvalue', console.log);

  // With a Promise:
  localforage.setItem('mykey', 'myvalue').then(console.log);
});