首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >未捕获的SyntaxError:意外的标记:(jquery)

未捕获的SyntaxError:意外的标记:(jquery)
EN

Stack Overflow用户
提问于 2018-06-05 07:41:56
回答 1查看 28关注 0票数 0

错误出现在单词init:之后,在函数之前。我是编程新手,不知道问题出在哪里。这是jquery。

代码语言:javascript
复制
init: function (options) {
        var self = this, o = this.options, c = o.classes, d = $(document), i;
        // Set up the cart configuration.
        $.extend(true, o, options);
        // Set up the storage method.
        this.saveCart = this.setStorageMethod(o.storage);
        if (this.saveCart) {
            this.webstore();
            // Get the shopping cart.
            o.properties = $.merge([ c.id, c.stock, c.price, c.quantity, o.title ], o.properties);
            this.saveCart(true);
            if (this.cart.timeout === null) {
                this.cart.timeout = this.timeout(true);
            }

            // Build the shopping cart.
            $.each(this.carts, function (cart) {
                d.delegate(cart + ' .' + c.remove, 'click', 'remove', $.proxy(self.listen, self));
                d.delegate(cart + ' :input', 'change', 'cart-options', $.proxy(self.listen, self));
                self.buildCart(cart);
            });
            // Update total amounts.
            this.updateTotals();
            o.ready.call(this);
        }
    }
EN

回答 1

Stack Overflow用户

发布于 2018-06-05 07:58:56

如果你想要一个名为'init‘的函数,只要把它放在函数后面就行了,如下所示:

代码语言:javascript
复制
function init(options) { }

除非你想通过原型创建你自己的jQuery函数:

代码语言:javascript
复制
jQuery.fn.extend({
    init: function(options){}
})

有关文档的更多信息,请单击此处:https://api.jquery.com/jquery.fn.extend/

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50690171

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档