[英]Uncaught SyntaxError: Unexpected token : (jquery)
The error comes after the word init: before the function. 错误出现在单词init之后:函数之前。 I'm newer to coding and not sure what the problem is. 我是编码新手,不确定是什么问题。 This is jquery. 这是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);
}
}
If you want a function named 'init' Just put it after function like so: 如果您想要一个名为“ init”的函数,只需将其放在函数之后,如下所示:
function init(options) { }
Unless you're wanting to create your own jQuery function via prototyping: 除非您想通过原型创建自己的jQuery函数,否则:
jQuery.fn.extend({
init: function(options){}
})
Read more on the documentation here: https://api.jquery.com/jquery.fn.extend/ 在此处阅读有关文档的更多信息: https : //api.jquery.com/jquery.fn.extend/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.