How to render a list of static content with Vue named slot? How to render a list of static content with Vue named slot? vue.js vue.js

How to render a list of static content with Vue named slot?


This is easily accomplished with a render function.

Vue.component("comp", {  render(h){    let links = this.$slots.links.map(l => h('li', {class: "comp-item"}, [l]))    return h('ul', {class: 'comp'}, links)  }})

Here is a working example.

console.clear()Vue.component("comp", {  render(h){    let links = this.$slots.links.map(l => h('li', {class: "comp-item"}, [l]))    return h('ul', {class: 'comp'}, links)  }})new Vue({  el: "#app"})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.13/vue.js"></script><div id="app">  <comp>    <a href="#" slot="links">link 1</a>    <a href="#" slot="links">link 2</a>  </comp></div>