我正在尝试将PersistJS库与ReactJS一起使用,但遇到很多错误,为了使其能够正常工作,我需要更改什么?
已经尝试通过以下方式从公用文件夹中将persist.min.js和index.html放入:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<script type='text/javascript' src='js/persist-min.js'></script>
...
但是当我从任何组件调用它时,都使用以下代码:
var store = new Persist.Store('My Application');
我收到此错误
'Persist' is not defined no-undef
当我尝试通过这种方式直接从组件导入时,会出现相同的错误:
import "../../utils/persist-min";
我还尝试了 franciscomemoli 在库的github上this issue上建议的方法,但出现此错误:
./src/js/persist.js
Line 31: 'google' is not defined no-undef
Line 40: 'GearsFactory' is not defined no-undef
Line 44: 'ActiveXObject' is not defined no-undef
Line 76: 'google' is not defined no-undef
Line 79: 'google' is not defined no-undef
Line 80: 'google' is not defined no-undef
Line 89: 'Persist' is not defined no-undef
Line 492: 'google' is not defined no-undef
Line 603: 'globalStorage' is not defined no-undef
Line 622: 'globalStorage' is not defined no-undef
Line 924: 'swfobject' is not defined no-undef
Line 932: 'swfobject' is not defined no-undef
Line 957: 'swfobject' is not defined no-undef
Line 1098: Unexpected use of 'location' no-restricted-globals
我在做什么错,如何在React应用程序中导入该库?