Uncaught ReferenceError: store is not defined
Uncaught ReferenceError: store is not defined
我正在使用 store.js 编写演示。
简而言之,有两个文件 index.html
和 base.js
以及文件夹 node_mudules
。
我通过以下方式安装 store.js:
npm i store
在index.html中,在header中引用:
<script src="node_modules/jquery/dist/jquery.js"></script>
<script src="js/base.js"></script>
<script src="node_modules/store/store.js"></script>
但是当我尝试在 base.js 中使用它时,例如:
store.set('user', { name:'Marcus' })
这个错误:
Uncaught ReferenceError: store is not defined
我确定路径是正确的,因为它的引用方式与 jquery 相同,并且 jquery 工作正常。
我还下载了整个 repo 并将 store.legacy.min.js
复制到我的项目中,在 header 中引用:
<script src="node_modules/jquery/dist/jquery.js"></script>
<script src="js/base.js"></script>
<script src="./store.legacy.min.js"></script>
同样的错误:
Uncaught ReferenceError: store is not defined
怎么了?非常感谢收到的任何帮助...
使用这个:
<script src="node_modules/store/store.js"></script>
<script src="node_modules/jquery/dist/jquery.js"></script>
<script src="js/base.js"></script>
我正在使用 store.js 编写演示。
简而言之,有两个文件 index.html
和 base.js
以及文件夹 node_mudules
。
我通过以下方式安装 store.js:
npm i store
在index.html中,在header中引用:
<script src="node_modules/jquery/dist/jquery.js"></script>
<script src="js/base.js"></script>
<script src="node_modules/store/store.js"></script>
但是当我尝试在 base.js 中使用它时,例如:
store.set('user', { name:'Marcus' })
这个错误:
Uncaught ReferenceError: store is not defined
我确定路径是正确的,因为它的引用方式与 jquery 相同,并且 jquery 工作正常。
我还下载了整个 repo 并将 store.legacy.min.js
复制到我的项目中,在 header 中引用:
<script src="node_modules/jquery/dist/jquery.js"></script>
<script src="js/base.js"></script>
<script src="./store.legacy.min.js"></script>
同样的错误:
Uncaught ReferenceError: store is not defined
怎么了?非常感谢收到的任何帮助...
使用这个:
<script src="node_modules/store/store.js"></script>
<script src="node_modules/jquery/dist/jquery.js"></script>
<script src="js/base.js"></script>