質問編集履歴
1
コードを追記しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -9,3 +9,191 @@
|
|
9
9
|
これは,パスの変更が発生しないのでtransitionが発生しないという認識であっているのでしょうか.
|
10
10
|
|
11
11
|
また,遷移アニメーションを付ける方法があればお伺いしたいです.
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
追記
|
16
|
+
|
17
|
+
記事データはCMSであるcontentfulから取得しています.
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
```vue
|
22
|
+
|
23
|
+
//index.vue
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
<template>
|
28
|
+
|
29
|
+
<div>
|
30
|
+
|
31
|
+
<section class="p-posts">
|
32
|
+
|
33
|
+
<Card
|
34
|
+
|
35
|
+
v-for="post in pagePosts"
|
36
|
+
|
37
|
+
:key="post.fields.slug"
|
38
|
+
|
39
|
+
:title="post.fields.title"
|
40
|
+
|
41
|
+
:slug="post.fields.slug"
|
42
|
+
|
43
|
+
:header-image="post.fields.headerImage"
|
44
|
+
|
45
|
+
:published-at="post.fields.publishedAt"
|
46
|
+
|
47
|
+
:tag="post.fields.tag.fields.tag"
|
48
|
+
|
49
|
+
:tag-slug="post.fields.tag.fields.tagSlug"
|
50
|
+
|
51
|
+
/>
|
52
|
+
|
53
|
+
</section>
|
54
|
+
|
55
|
+
<article class="pagination">
|
56
|
+
|
57
|
+
<v-pagination
|
58
|
+
|
59
|
+
v-model="page"
|
60
|
+
|
61
|
+
:length="length"
|
62
|
+
|
63
|
+
:circle="true"
|
64
|
+
|
65
|
+
color="#00aca3"
|
66
|
+
|
67
|
+
@input = "pageChange"
|
68
|
+
|
69
|
+
/>
|
70
|
+
|
71
|
+
</article>
|
72
|
+
|
73
|
+
</div>
|
74
|
+
|
75
|
+
</template>
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<script>
|
80
|
+
|
81
|
+
import { createClient } from "~/plugins/contentful.js";
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
const client = createClient();
|
86
|
+
|
87
|
+
export default {
|
88
|
+
|
89
|
+
transition: "fade",
|
90
|
+
|
91
|
+
data () {
|
92
|
+
|
93
|
+
return {
|
94
|
+
|
95
|
+
page: 1,
|
96
|
+
|
97
|
+
pagePosts: [],
|
98
|
+
|
99
|
+
pageSize: 6,
|
100
|
+
|
101
|
+
length:0,
|
102
|
+
|
103
|
+
}
|
104
|
+
|
105
|
+
},
|
106
|
+
|
107
|
+
async asyncData({ env, params }) {
|
108
|
+
|
109
|
+
return await client
|
110
|
+
|
111
|
+
.getEntries({
|
112
|
+
|
113
|
+
content_type: env.CTF_BLOG_POST_TYPE_ID,
|
114
|
+
|
115
|
+
order: "-fields.publishedAt",
|
116
|
+
|
117
|
+
})
|
118
|
+
|
119
|
+
.then(entries => {
|
120
|
+
|
121
|
+
return {
|
122
|
+
|
123
|
+
posts: entries.items
|
124
|
+
|
125
|
+
};
|
126
|
+
|
127
|
+
})
|
128
|
+
|
129
|
+
.catch(console.error);
|
130
|
+
|
131
|
+
},
|
132
|
+
|
133
|
+
mounted: function(){
|
134
|
+
|
135
|
+
this.posts
|
136
|
+
|
137
|
+
this.pagePosts = this.posts.slice(0,this.pageSize)
|
138
|
+
|
139
|
+
this.length = Math.ceil(this.posts.length/this.pageSize);
|
140
|
+
|
141
|
+
},
|
142
|
+
|
143
|
+
methods: {
|
144
|
+
|
145
|
+
pageChange: function(pageNumber){
|
146
|
+
|
147
|
+
this.pagePosts = this.posts.slice(this.pageSize*(pageNumber -1), this.pageSize*(pageNumber))
|
148
|
+
|
149
|
+
},
|
150
|
+
|
151
|
+
},
|
152
|
+
|
153
|
+
};
|
154
|
+
|
155
|
+
</script>
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
<style>
|
160
|
+
|
161
|
+
.fade-enter-active,
|
162
|
+
|
163
|
+
.fade-leave-active {
|
164
|
+
|
165
|
+
transition: all .5s ease-out;
|
166
|
+
|
167
|
+
}
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
.fade-enter,
|
172
|
+
|
173
|
+
.fade-leave-to {
|
174
|
+
|
175
|
+
opacity: 0;
|
176
|
+
|
177
|
+
}
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
.fade-enter {
|
182
|
+
|
183
|
+
transform: translateY(15px);
|
184
|
+
|
185
|
+
}
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
.pagination {
|
190
|
+
|
191
|
+
margin-top: 64px;
|
192
|
+
|
193
|
+
}
|
194
|
+
|
195
|
+
</style>
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
```
|