Skip to content

Commit 40de8e7

Browse files
Update index.html
1 parent 27d61ba commit 40de8e7

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

index.html

+22-13
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ <h2 class="title">{{infos.title}}</h2>
5252
const app = new Vue({
5353
el: '#app',
5454
data: {
55-
infos: info,
56-
albums: json,
55+
infos: {}, // Khởi tạo rỗng
56+
albums: {}, // Khởi tạo rỗng
5757
},
5858
computed: {
5959
totalImages() {
@@ -98,17 +98,26 @@ <h2 class="title">{{infos.title}}</h2>
9898
}
9999
},
100100
async mounted() {
101-
// Sử dụng fetch để lấy dữ liệu JSON
102-
const [infoRes, albumsRes] = await Promise.all([
103-
fetch('./data/info.json'),
104-
fetch('./data/config.json')
105-
]);
106-
this.infos = await infoRes.json();
107-
this.albums = await albumsRes.json();
108-
109-
document.title = this.infos.name;
110-
this.albumsCountAnimation();
111-
this.initImgPreviewer();
101+
try {
102+
// Nạp dữ liệu từ các tệp JSON
103+
const [infoRes, albumsRes] = await Promise.all([
104+
fetch('./data/info.json'),
105+
fetch('./data/config.json')
106+
]);
107+
108+
// Gán dữ liệu vào các thuộc tính Vue
109+
this.infos = await infoRes.json();
110+
this.albums = await albumsRes.json();
111+
112+
// Thiết lập tiêu đề trang
113+
document.title = this.infos.name;
114+
115+
// Chạy các chức năng bổ sung
116+
this.albumsCountAnimation();
117+
this.initImgPreviewer();
118+
} catch (error) {
119+
console.error('Error loading JSON data:', error);
120+
}
112121
}
113122
});
114123
</script>

0 commit comments

Comments
 (0)