gpt4 book ai didi

javascript - Backbone.LocalStorage 不是函数

转载 作者:可可西里 更新时间:2023-11-01 13:04:13 26 4
gpt4 key购买 nike

我正在使用 backbone localstorage 插件,但是它给了我以下错误。

Uncaught TypeError: Backbone.LocalStorage is not a function

我在我的收藏中按照以下方式使用它

var TodoList = Backbone.Collection.extend({
model: TodoModel,
localStorage: new Backbone.LocalStorage('todos-backbone')
});

我该如何解决这个问题?

更新

我将它们导入到 index.html 中

<script src="node_modules/jquery/dist/jquery.min.js"></script>
<script src="node_modules/backbone/node_modules/underscore/underscore-min.js"></script>
<script src="node_modules/backbone/backbone-min.js"></script>
<script src="node_modules/backbone-localstorage/backbone-localStorage.js"></script>
<script src="js/models/todo.js"></script>
<script src="js/collections/todos.js"></script>
<script src="js/views/todos.js"></script>
<script src="js/views/app.js"></script>
<!-- <script src="js/routers/router.js"></script> -->
<script src="js/app.js"></script>

最佳答案

我觉得你很困惑https://github.com/jeromegn/Backbone.localStoragehttps://github.com/robmoorman/backbone-localstorage . Backbone.LocalStorage 仅在前者中是一个函数,而您包含的函数是这样使用的:

var TodoList = Backbone.Collection.extend({
model: TodoModel,
localStorage: true
});

关于javascript - Backbone.LocalStorage 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35013302/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com