0

I am trying to understand the vue virtual scroller. I noticed in the demo there are a couple HTML attributes it uses...

<virtual-scroller v-if="scopedSlots" class="scroller" :item-height="itemHeight" :items="items" main-tag="section" content-tag="table" :buffer="buffer" :pool-size="poolSize">

link to the specific line on source code

Where does this ability come from and where is the documentation for it?

LiranC
  • 2,400
  • 1
  • 27
  • 55
Jackie
  • 21,969
  • 32
  • 147
  • 289

2 Answers2

0

Breakdown:

please notice that item-height for example is written as kebab-case on the html side, but should be written with camelCase on the javascript side. like so: itemHeight

about the content-tag, main-tag - worth a shot to ask the developer on github. those are not part of official vue api, nor part of html spec.

tony19
  • 125,647
  • 18
  • 229
  • 307
LiranC
  • 2,400
  • 1
  • 27
  • 55
0

These are props declared in ../src/components/VirtualScroller.vue.

Both "content-tag" and "main-tag" are props of type String, meaning you can pass your choice of html elements. In your copied example, "section" and "table" is being passed to each prop, which is simply a string. If no value is passed, it would default to "div", which was set here: https://github.com/Akryum/vue-virtual-scroller/blob/master/src/components/VirtualScroller.vue

The string can also be passed dynamically, as they do for :item-height="itemHeight", where you would have :main-tag="mainTag" or :main-tag="anyCustomMainTag". This would allow you to set mainTag or anyCustomMainTag to your string value, which would also override the default div.