写好了一个网页,引入js的数据文件,可是显示属性未定义
引入的js代码"categoryList": [{
"bannerUrl": "http://yanxuan.nosdn.127.net/c031900229c9f056bf65de64cc600522.jpg",
"frontDesc": "挑选,你的生活",
"frontName": "挑选,你的生活",
"iconUrl": "http://yanxuan.nosdn.127.net/7093cfecb9dde1dd3eaf459623df4071.png",
"id": 1019000,
"level": "L1",
"name": "其他",
"showIndex": 9,
"subCateList": [],
"superCategoryId": 0
}, {
js代码:var params = yx.parseUrl(window.location.href);
var pageId = params.id; //产品对应的id
var curData = productList[pageId]; //产品对应的数据
// if (!pageId || !curData) {
// //这个就是404页面出现在条件
// // window.location.href='404.html';
// }
//面包屑的功能
var positionFn = yx.g('#position');
positionFn.innerHTML = 'https://ask.csdn.net/new?word=&spm=1020.2143.3001.5354# >';
for (var i = 0; i < curData.categoryList.length; i++) {
positionFn.innerHTML += ' https://ask.csdn.net/new?word=&spm=1020.2143.3001.5354# >';
}
positionFn.innerHTML += curData.name;
//http://www.kaivon.cn/getData.php?id=1131017
//产品图功能
(function() {
//左边图片切换功能
var bigImg = yx.g('#productImg .left img');
var smallImgs = yx.ga('#productImg .smallImg img');
bigImg.src = smallImgs[0].src = curData.primaryPicUrl;
var last = smallImgs[0]; //上一张图片
for (var i = 0; i < smallImgs.length; i++) {
if (i) {
//这个条件满足的话,说明现在是后四张图片
smallImgs[i].src = curData.itemDetail['picUrl' + i];
}
smallImgs[i].index = i;
smallImgs[i].onmouseover = function() {
bigImg.src = this.src;
last.className = '';
this.className = 'active';
last = this;
};
}
Uncaught TypeError: Cannot read properties of undefined (reading 'categoryList')
curData.categoryList.length这个东西显示属性未定义
一直找问题迟迟没找到,路径也对
麻烦帮我看看
console.log(curData) 看看 categoryList 存不存在 是不是有值且为数组