-1
如何修復錯誤遺漏的類型錯誤:無法讀取的不確定上app.js財產「推」:57遺漏的類型錯誤:無法讀取app.js的未定義的屬性「推」:57
我有文件JS app.js
與行代碼在這裏:
url = 'https://siayi.github.io/website-desa/sites.json';
$.getJSON(url, function (json) {
count = new WebsiteCounter(json);
$("#total").html(count.count);
$("#kecamatan").html(count.kecamatan);
$("#kabkot").html(count.kabkot);
console.log(count);
$(".render-bar").toggle();
tables = new WebsiteTable(json);
$.each(tables, function(key,table) {
$("#tables").append(table);
});
});
function WebsiteTable(data) {
var tables = [];
var headers = ["Desa", "Kecamatan", "Kabupaten/Kota"];
var formatted = {
"Aceh": [],
"Sumatera Utara": [],
"Sumatera Barat": [],
"Riau": [],
"Papua Barat": []
};
$.each(data, function(key,site) {
formatted[site.provinsi].push([site.title, site.kecamatan, site.kabkot, site.url])
});
在'$ .each' FUNC,** **格式爲空。檢查每個循環中是否存在關鍵site.provinsi。如果可以的話,向我們展示控制檯日誌。 –
這裏是我的控制檯日誌: '未捕獲的TypeError:無法讀取Object上未定義的 的屬性'push'。 (jquery.js:368) at new WebsiteTable(app.js:56) at Object.success(app.js:9) at fire(jquery.js)() :3305) at Object.fireWith [as resolveWith](jquery.js:3435) at done(jquery.js:9242) at XMLHttpRequest。(jquery.js:9484)' –