v.0.0.2 bring typing into game
This commit is contained in:
Generated
+7
@@ -8,6 +8,7 @@
|
|||||||
"name": "tmp-app-creation",
|
"name": "tmp-app-creation",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@types/axios": "^0.9.36",
|
||||||
"axios": "^1.20.0",
|
"axios": "^1.20.0",
|
||||||
"vue": "^3.5.42"
|
"vue": "^3.5.42"
|
||||||
},
|
},
|
||||||
@@ -816,6 +817,12 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/axios": {
|
||||||
|
"version": "0.9.36",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/axios/-/axios-0.9.36.tgz",
|
||||||
|
"integrity": "sha512-NLOpedx9o+rxo/X5ChbdiX6mS1atE4WHmEEIcR9NLenRVa5HoVjAvjafwU3FPTqnZEstpoqCaW7fagqSoTDNeg==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "24.13.5",
|
"version": "24.13.5",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.13.5.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.13.5.tgz",
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
"type-check": "vue-tsc --build"
|
"type-check": "vue-tsc --build"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@types/axios": "^0.9.36",
|
||||||
"axios": "^1.20.0",
|
"axios": "^1.20.0",
|
||||||
"vue": "^3.5.42"
|
"vue": "^3.5.42"
|
||||||
},
|
},
|
||||||
|
|||||||
+3
-1
@@ -35,6 +35,8 @@ document.title = `${pkg.name} ${pkg.version}©2026`;
|
|||||||
rgba(180, 231, 207, 0.5),
|
rgba(180, 231, 207, 0.5),
|
||||||
rgba(28, 72, 167, 0.6)
|
rgba(28, 72, 167, 0.6)
|
||||||
);
|
);
|
||||||
width: 30%;
|
width: 32%;
|
||||||
|
padding: 5px;
|
||||||
|
border-radius: 15px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,21 +1,24 @@
|
|||||||
<script setup>
|
<script setup lang="ts">
|
||||||
import { onMounted, ref, toRaw } from "vue";
|
import { onMounted, ref } from "vue";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
import type { Album } from "@/types/album";
|
||||||
|
|
||||||
const albums = ref([]);
|
const album_titles = ref<string[]>([]);
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async (): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
// Axios automatically parses the JSON response into 'response.data'
|
// Axios automatically parses the JSON response into 'response.data'
|
||||||
const albums_response = await axios.get(
|
const albums_response = await axios.get<Album[]>(
|
||||||
"https://jsonplaceholder.typicode.com/albums",
|
"https://jsonplaceholder.typicode.com/albums",
|
||||||
);
|
);
|
||||||
|
|
||||||
albums.value = albums_response.data
|
console.log("albums_response:", albums_response.data);
|
||||||
|
|
||||||
|
album_titles.value = albums_response.data
|
||||||
.slice(0, 12)
|
.slice(0, 12)
|
||||||
.map((album) => album.title);
|
.map((album) => album.title);
|
||||||
|
|
||||||
console.log("alb_titles:", [...albums.value]);
|
console.log("album_titles:", [...album_titles.value]);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching albums!", error);
|
console.error("Error fetching albums!", error);
|
||||||
}
|
}
|
||||||
@@ -26,8 +29,8 @@ onMounted(async () => {
|
|||||||
<div class="card">
|
<div class="card">
|
||||||
<h3>Albums List</h3>
|
<h3>Albums List</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<li v-for="(album, index) in albums" :key="index">
|
<li v-for="(album_title, index) in album_titles" :key="index">
|
||||||
{{ album }}
|
{{ album_title }}
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
<script setup>
|
<script setup lang="ts">
|
||||||
import { onMounted, ref } from "vue";
|
import { ref } from "vue";
|
||||||
|
|
||||||
const msg = ref("Tom is building a vue template, oh yeah");
|
const msg = ref<string>("Tom is building a vue template, oh yeah");
|
||||||
const status = ref(true);
|
const status = ref<boolean>(true);
|
||||||
|
|
||||||
// Define function directly
|
// Define function directly
|
||||||
const toggleStatus = () => {
|
const toggleStatus = (): void => {
|
||||||
status.value = !status.value;
|
status.value = !status.value;
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script setup>
|
<script setup lang="ts">
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
|
|
||||||
const a = ref(true);
|
const a = ref<boolean>(true);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
export interface Album {
|
||||||
|
userId: number;
|
||||||
|
id: number;
|
||||||
|
title: string;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user