@@ -203,10 +203,10 @@ at `/:dinosaur`.
203
203
Finally, you can delete all of the code in the ` src/ App .vue ` file to and update
204
204
it to include only the ` < RouterView> ` component:
205
205
206
- ` ` ` vue title= " App.vue"
206
+ ` ` ` html title= " App.vue"
207
207
< template>
208
208
< RouterView / >
209
- < / template> ;
209
+ < / template>
210
210
` ` `
211
211
212
212
### The components
@@ -231,25 +231,27 @@ up earlier and render them as links using the
231
231
` lang= " ts" ` attribute on the script tag.) Add the following code to the
232
232
` Dinosaurs .vue ` file:
233
233
234
- ` ` ` vue title= " Dinosaurs.vue"
234
+ ` ` ` html title= " Dinosaurs.vue"
235
235
< script lang= " ts" >
236
- import { defineComponent } from ' vue' ;
236
+ import { defineComponent } from " vue" ;
237
237
238
- export default defineComponent ({
238
+ export default defineComponent ({
239
239
async setup () {
240
- const res = await fetch (" http://localhost:8000/dinosaurs" )
241
- const dinosaurs = await res .json () as Dinosaur[];
242
- return { dinosaurs };
243
- }
244
- });
240
+ const res = await fetch (" http://localhost:8000/dinosaurs" );
241
+ const dinosaurs = await res .json () as Dinosaur[];
242
+ return { dinosaurs };
243
+ },
244
+ });
245
245
< / script>
246
246
247
247
< template>
248
- < div v- for = " dinosaur in dinosaurs" : key= " dinosaur.name" >
249
- < RouterLink : to= " { name: 'Dinosaur', params: { dinosaur: `${dinosaur.name.toLowerCase()}` } }" >
250
- {{ dinosaur .name }}
251
- < / RouterLink>
252
- < / div>
248
+ < div v- for = " dinosaur in dinosaurs" : key= " dinosaur.name" >
249
+ < RouterLink
250
+ : to= " { name: 'Dinosaur', params: { dinosaur: `${dinosaur.name.toLowerCase()}` } }"
251
+ >
252
+ {{ dinosaur .name }}
253
+ < / RouterLink>
254
+ < / div>
253
255
< / template>
254
256
` ` `
255
257
@@ -265,9 +267,9 @@ uniquely identify each dinosaur.
265
267
The homepage will contain a heading and then it will render the ` Dinosaurs`
266
268
component. Add the following code to the ` HomePage .vue ` file:
267
269
268
- ` ` ` vue title= " HomePage.vue"
270
+ ` ` ` html title= " HomePage.vue"
269
271
< script setup lang= " ts" >
270
- import Dinosaurs from ' ./Dinosaurs.vue' ;
272
+ import Dinosaurs from " ./Dinosaurs.vue" ;
271
273
< / script>
272
274
< template>
273
275
< h1> Welcome to the Dinosaur App! 🦕< / h1>
@@ -308,28 +310,30 @@ type ComponentData = {
308
310
309
311
Then update the ` Dinosaur .vue ` file:
310
312
311
- ` ` ` vue title= " Dinosaur.vue"
313
+ ` ` ` html title= " Dinosaur.vue"
312
314
< script lang= " ts" >
313
- import { defineComponent } from ' vue' ;
315
+ import { defineComponent } from " vue" ;
314
316
315
- export default defineComponent ({
317
+ export default defineComponent ({
316
318
props: { dinosaur: String },
317
319
data (): ComponentData {
318
- return {
319
- dinosaurDetails: null
320
- };
320
+ return {
321
+ dinosaurDetails: null ,
322
+ };
321
323
},
322
324
async mounted () {
323
- const res = await fetch (` http://localhost:8000/dinosaurs/${ this .dinosaur } ` );
324
- this .dinosaurDetails = await res .json ();
325
- }
326
- });
325
+ const res = await fetch (
326
+ ` http://localhost:8000/dinosaurs/${ this .dinosaur } ` ,
327
+ );
328
+ this .dinosaurDetails = await res .json ();
329
+ },
330
+ });
327
331
< / script>
328
332
329
333
< template>
330
- < h1> {{ dinosaurDetails? .name }}< / h1>
331
- < p> {{ dinosaurDetails? .description }}< / p>
332
- < RouterLink to= " /" > 🠠 Back to all dinosaurs< / RouterLink>
334
+ < h1> {{ dinosaurDetails? .name }}< / h1>
335
+ < p> {{ dinosaurDetails? .description }}< / p>
336
+ < RouterLink to= " /" > 🠠 Back to all dinosaurs< / RouterLink>
333
337
< / template>
334
338
` ` `
335
339
0 commit comments