错误出现在单词init:之后,在函数之前。我是编程新手,不知道问题出在哪里。这是jquery。
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);
}
}
发布于 2018-06-05 07:58:56
如果你想要一个名为'init‘的函数,只要把它放在函数后面就行了,如下所示:
function init(options) { }
除非你想通过原型创建你自己的jQuery函数:
jQuery.fn.extend({
init: function(options){}
})
有关文档的更多信息,请单击此处:https://api.jquery.com/jquery.fn.extend/
https://stackoverflow.com/questions/50690171
复制相似问题