mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 07:05:11 +00:00
e934da3c36
Co-authored-by: Renovate Bot <bot@renovateapp.com> Co-authored-by: Clark Du <clark.duxin@gmail.com>
50 lines
929 B
Vue
50 lines
929 B
Vue
<template>
|
|
<div v-if="Car">
|
|
<h3>{{ Car.make }} {{ Car.model }}</h3>
|
|
<p>{{ formatCurrency(Car.price) }}</p>
|
|
<img :src="Car.photoURL" :alt="`${Car.model} photo`">
|
|
<p>
|
|
<NuxtLink to="/">
|
|
Home page
|
|
</NuxtLink>
|
|
</p>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import car from '~/apollo/queries/car'
|
|
|
|
export default {
|
|
apollo: {
|
|
Car: {
|
|
query: car,
|
|
prefetch: ({ route }) => ({ id: route.params.id }),
|
|
variables () {
|
|
return { id: this.$route.params.id }
|
|
}
|
|
}
|
|
},
|
|
head () {
|
|
return {
|
|
title: (this.Car ? `${this.Car.make} ${this.Car.model}` : 'Loading')
|
|
}
|
|
},
|
|
methods: {
|
|
formatCurrency (num) {
|
|
const formatter = new Intl.NumberFormat('en-US', {
|
|
style: 'currency',
|
|
currency: 'USD',
|
|
minimumFractionDigits: 2
|
|
})
|
|
return formatter.format(num)
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
img {
|
|
max-width: 600px;
|
|
}
|
|
</style>
|