mirror of
https://github.com/nuxt/nuxt.git
synced 2024-12-02 10:27:15 +00:00
added paramterized car view
This commit is contained in:
parent
3893e191ed
commit
018934eeed
33
examples/vue-apollo/pages/car/_id.vue
Normal file
33
examples/vue-apollo/pages/car/_id.vue
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<template>
|
||||||
|
<section>
|
||||||
|
<article class="car-art">
|
||||||
|
<span>{{Car.make}}</span><br>
|
||||||
|
<span>{{Car.model}}</span><br>
|
||||||
|
<span>{{Car.year}}</span>
|
||||||
|
</article>
|
||||||
|
<nuxt-link to="/">Home</nuxt-link>
|
||||||
|
</section>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "Car",
|
||||||
|
apollo: {
|
||||||
|
Car: {
|
||||||
|
query: gql`query car($id: ID) {Car(id: $id) {make model year}}`,
|
||||||
|
variables () {
|
||||||
|
return {
|
||||||
|
id: this.$route.params.id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
Car: {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
Loading…
Reference in New Issue
Block a user