1

我被难住了。我正在以正确的顺序加载我的脚本,正如查看源代码所确认的那样,我仍然在控制台中收到此错误:

 app.TodoList = Backbone.Collection.extend({
    model: app.Todo,
    localStorage: new Backbone.LocalStorage("backbone-todo")
    // Uncaught TypeError: undefined is not a function
 });

app.todoList = new app.TodoList();

这是我对脚本进行排队的方式:

function av_one_load_scripts() {
    wp_register_script( 'backbone_localstorage', 'https://raw.github.com/jeromegn/Backbone.localStorage/master/backbone.localStorage-min.js', array( 'backbone' ) );
    wp_register_script( 'bb_one', get_stylesheet_directory_uri() . '/js/bb_one.js', array( 'jquery', 'backbone', 'backbone_localstorage' ) );

    wp_enqueue_script( 'backbone' );
    wp_enqueue_script( 'backbone_localstorage' );
    wp_enqueue_script( 'bb_one' );
}
add_action( 'wp_enqueue_scripts', 'av_one_load_scripts' );

这个问题围绕着一个过时的本地存储脚本,所以我正在遵循示例但仍然收到错误。有任何想法吗?

4

0 回答 0