我已使用此代碼。變量未定義Google控制檯
但在谷歌控制檯我得到這個錯誤:未捕獲的ReferenceError:
this.createSavedStickers = function(stickersJSON) {
try {
stickers = JSON.parse(stickersJSON);
} catch (e) {
for (var i in stickers) {
sticker_properties = JSON.parse(stickers[i].properties);
var from_left = this.calcLeft(sticker_properties.from_center);
sticker = jQuery('<div/>', {
id: stickers[i].sticker_id,
class: 'wpst-sticker-note sticked saved',
"data-from-center": sticker_properties.from_center,
css: {
"top": sticker_properties.top + "px",
"left": from_left + "px",
"position": "absolute"
}
}).appendTo('body');
sticker.html(this.stickerHTML).find(".textarea").html(stickers[i].note);
sticker.find(".resize").css({
width: sticker_properties.width + "px",
height: sticker_properties.height + "px"
});
this.bindEvents(sticker);
this.allStickers.push(sticker);
}
console.log(e);
}
}
感謝您的幫助
爲什麼代碼處理catch塊中的貼紙? –
你爲什麼要在'catch'塊中使用'stickers'。如果'try'中的一行失敗,''''''''確實會被undefined – Rhumborl