简体   繁体   中英

Uncaught TypeError: Cannot read property 'photos' of undefined

This code:

$.each(variant['photos'], function( index, object ) {
            object['idx'] = index;
            if(index == 0) object['active'] = true;
        });

produces following error:

error Uncaught TypeError: Cannot read property 'photos' of undefined

图片

Well, that error message is pretty self explanatory. You are attempting to read a property of something that isn't defined. In this case, the error comes from variant['photos'] . You haven't defined variant .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM