未捕获ReferenceError:未在HTMLButtonElement上定义用户。<anonymous>如何解决此问题?

时间:2020-08-09 15:54:51

标签: javascript html css

谁能告诉我该如何解决?它说未定义用户,thx

var updateBtns = document.getElementsByClassName('update-cart')

for(var i = 0; i < updateBtns.length; i++){
    updateBtns[i].addEventListener('click', function(){
        var productId = this.dataset.product
        var action = this.dataset.action
        console.log('productId:', productId, 'action:', action )

        console.log('USER:', user)
        if(user == 'AnonymousUser'){
            console.log('Not logged in')
            } else {
              updateUserOrder(productId, action)
       } })

}

0 个答案:

没有答案