hilongjw / vue-recyclerview

Mastering Large Lists with the vue-recyclerview
https://hilongjw.github.io/vue-recyclerview/
MIT License
1.45k stars 121 forks source link

Is it possible to pass extra props to component? #12

Closed vbabenko closed 7 years ago

vbabenko commented 7 years ago

Currently it looks like this: `<RecyclerView :prerender="30" :fetch="MiFetch" :item="MiItem" :tombstone="MiTomstone"

`

and RecyclerView will pass only one props data to item.

Is it possible somehow to pass extra props like this `<RecyclerView :prerender="30" :fetch="MiFetch" :item="MiItem" :tombstone="MiTomstone" :propOne="myProp1" :propTwo="myProp2"

` Thanks

hilongjw commented 7 years ago

Hi @vbabenko , I think: ` propTwo= 'myProp2' is not a good way, the name of the props here can not be customized, can only be fixed to propTwo, propThree etc.

I think the way through options will be better

options: {
  props: {
    user: user,
    other: otherData
    ...
  }
}
<RecyclerView 
:prerender="30"
:remain="30"
 :fetch="MiFetch"
 :item="MiItem" 
:tombstone="MiTomstone"
 :options="options">
</RecyclerView>

item renderer

vm = new this.Vue({
      el: el,
      render: h => h(this.itemRender, {
        props: {
          data: data
          ...options.props
        }
    })
 })
vbabenko commented 7 years ago

@hilongjw Thanks, it works

hazzo commented 7 years ago

Sorry @hilongjw but I think that this option of passing props its not available in the last npm build. Could be possible? Because my source file it's not the same as the one here in github.

Thanks again

hazzo commented 7 years ago

Heheh also @inited event is missing. I think you are on version 0.3.4 and NPM staid on 0.3.3

hilongjw commented 7 years ago

@hazzo I just published 0.3.5 on npm

hazzo commented 7 years ago

Thanks!