11<template >
22 <div class =" item-view" v-if =" item" >
3- <div class =" item-view-header" >
4- <a :href =" item.url" target =" _blank" >
5- <h2 >{{ item.title }}</h2 >
6- </a >
7- <span v-if =" item.url" >({{ item.url | host }})</span >
8- <p >
9- {{ item.score }} points
10- | by <router-link :to =" '/user/' + item.by" >{{ item.by }}</router-link >
11- {{ item.time | timeAgo }} ago
12- | {{ item.descendants }} comments
13- </p >
14- </div >
15- <ul v-if =" item.kids" class =" item-view-comments" >
16- <comment v-for =" id in item.kids" :id =" id" ></comment >
17- </ul >
3+ <spinner :show =" !item" ></spinner >
4+ <template v-if =" item " >
5+ <div class =" item-view-header" >
6+ <a :href =" item.url" target =" _blank" >
7+ <h2 >{{ item.title }}</h2 >
8+ </a >
9+ <span v-if =" item.url" >({{ item.url | host }})</span >
10+ <p >
11+ {{ item.score }} points
12+ | by <router-link :to =" '/user/' + item.by" >{{ item.by }}</router-link >
13+ {{ item.time | timeAgo }} ago
14+ | {{ item.descendants }} comments
15+ </p >
16+ </div >
17+ <ul v-if =" item.kids" class =" item-view-comments" >
18+ <comment v-for =" id in item.kids" :id =" id" ></comment >
19+ </ul >
20+ </template >
1821 </div >
1922</template >
2023
2124<script >
25+ import Spinner from ' ../components/Spinner.vue'
2226import Comment from ' ../components/Comment.vue'
2327
2428function fetchItem (store ) {
@@ -29,7 +33,7 @@ function fetchItem (store) {
2933
3034export default {
3135 name: ' item-view' ,
32- components: { Comment },
36+ components: { Spinner, Comment },
3337 computed: {
3438 item () {
3539 return this .$store .state .items [this .$route .params .id ]
0 commit comments