Skip to content

Commit 6536a64

Browse files
committed
refactor: 优化动态加载性能
1 parent 2fe0020 commit 6536a64

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pages/feed/index.vue

+7-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ export default {
6363
data () {
6464
return {
6565
typeMap,
66-
feeds: [],
66+
new: [],
67+
hot: [],
6768
pinneds: [],
6869
}
6970
},
@@ -79,6 +80,9 @@ export default {
7980
this.$router.push({ ...this.$route, query: { type: val } })
8081
},
8182
},
83+
feeds () {
84+
return this.$data[this.type]
85+
},
8286
},
8387
watch: {
8488
type () {
@@ -89,7 +93,7 @@ export default {
8993
const { type = defaultType } = query
9094
const { feeds, pinned } = await $axios.$get('/feeds', { params: { type } })
9195
return {
92-
feeds,
96+
[type]: feeds,
9397
pinneds: pinned,
9498
}
9599
},
@@ -100,7 +104,7 @@ export default {
100104
async fetchFeeds () {
101105
const params = { type: this.type }
102106
const { feeds, pinned } = await this.$axios.$get('/feeds', { params })
103-
this.feeds = feeds
107+
this.$data[this.type] = feeds
104108
this.pinneds = pinned
105109
},
106110
},

0 commit comments

Comments
 (0)