未捕获的TypeError:this._triggerEvent不是jQuery SmartCart的函数

时间:2018-08-10 17:30:09

标签: javascript jquery cart

更新数量或从购物车中删除物品时,收到此错误。知道如何解决这个问题吗?

    _triggerEvent: function (name, params) {
        // Trigger an event
        var e = $.Event(name);
        this.cart_element.trigger(e, params);
        if (e.isDefaultPrevented()) {
            return false;
        }
        return e.result;
    }

    _removeFromCart: function (unique_key) {
        var mi = this;
        $.each(this.cart, function (i, n) {
            if (n.unique_key === unique_key) {
                var itemRemove = mi.cart[i];
                mi.cart.splice(i, 1);
                $('*[data-product-unique-key="' + unique_key + '"]').removeClass('sc-added-item');
                mi._hasCartChange();

                // Trigger "itemRemoved" event
                this._triggerEvent("itemRemoved", [itemRemove]);
                return false;
            }
        });
    }

GitHub

jQuery Script Demo

Error Screenshot

enter image description here

Code Screenshot

enter image description here

1 个答案:

答案 0 :(得分:0)

问题已解决。我已更改此代码 从this._triggerEvent("itemRemoved", [itemRemove]);mi._triggerEvent("itemRemoved", [itemRemove]);,第291行

this._triggerEvent("quantityUpdated", [mi.cart[i], qty]);mi._triggerEvent("quantityUpdated", [mi.cart[i], qty]);,在第318行