下面的代码在第3行打破,因为等号,但我不确定如何逃避它。有人可以帮助我吗?
if (window.location.href.match(/\/shop\/\?category/)) {
jQuery('body').addClass('shop-category');
} else if (window.location.href.match(/\/shop\/\?category=Chef)) {
jQuery('body').addClass('shop-category-chef');
} else if (window.location.href.match(new RegExp('/shop/.+')) ) {
jQuery('body').addClass('shop-item');
} else if (window.location.href.match('/shop/')) {
jQuery('body').addClass('shop');
}
答案 0 :(得分:2)
第三行缺少斜线:
if (window.location.href.match(/\/shop\/\?category/)) {
jQuery('body').addClass('shop-category');
} else if (window.location.href.match(/\/shop\/\?category=Chef/)) {
jQuery('body').addClass('shop-category-chef');
} else if (window.location.href.match(new RegExp('/shop/.+')) ) {
jQuery('body').addClass('shop-item');
} else if (window.location.href.match('/shop/')) {
jQuery('body').addClass('shop');
}