vue-hackernews 2.0里的这段代码是什么意思?(完全蒙蔽中ing)
发布于 8 年前 作者 QuoniamYIF 5683 次浏览 来自 问答

路径 vue-hackernews-2.0/src/views/CreateListView.js

import ItemList from '../components/ItemList.vue'

// This is a factory function for dynamically creating root-level list views,
// since they share most of the logic except for the type of items to display.
// They are essentially higher order components wrapping ItemList.vue.
export function createListView (type) {
  return {
    name: `${type}-stories-view`,
    // this will be called during SSR to pre-fetch data into the store!
    preFetch (store) {
      return store.dispatch('FETCH_LIST_DATA', { type })
    },
    render (h) {
      return h(ItemList, { props: { type }})
    }
  }
}
1 回复

render 是 2.0 引入的写法. prefFetch 是暴露给路由预加载的钩子

回到顶部