J
J
jeruthadam2019-03-15 22:11:50
Vue.js
jeruthadam, 2019-03-15 22:11:50

How to make v-for in render function?

I found an example in the doc, but it doesn't really fit my case.

<render-function-playground :layers="10">
        <h1>Hello</h1>
</render-function-playground>


render: function (createElement) {
    return createElement(
      'div',
      this.$slots.default
    )
  },
  props: {
    layers: {
      type: Number,
      required: true
    },
  }


How do I repeat a slot <h1>Hello</h1>10 times inside a render function? It is inside, rather than doing a cycle in the parent.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2020-06-13
@jeruthadam

functional: true,
render: (h, ctx) => h('div', Array(ctx.props.количествоПовторений).fill(ctx.slots().default)),

https://jsfiddle.net/pw8nubhc/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question