JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.10/vue.js"></script>
<div id="vue">
<basic-table>
<table-cell>{{ item.id }}</table-cell>
<table-cell>{{ item.title }}</table-cell>
</basic-table>
</div>
JavaScript
Vue.directive('slot', {
bind: function () {
var host = this.vm;
var root = host.$root;
var raw = host.$options._content;
// TODO: Insert your custom logic to decide what element goes here
for (var i = 0; i < raw.children.length; i++) {
var node = raw.children[i].cloneNode(true);
this.el.appendChild(node);
root.$compile(node, host, this._scope);
}
}
});
Vue.component('basic-table', {
template: '<table border="1" class="table"><tbody><tr v-for="item in collection" v-slot></tr></tbody></table>',
data: function () {
return {
collection: [
{id: 1, title: 'Vue'},
{id: 2, title: 'Vue 2'},
{id: 3, title: 'Vue 3'},
{id: 4, title: 'Vue 4'},
]
}
}
})
Vue.component('table-cell', {
template: '<td><slot></slot></td>'
})
new Vue({
el: '#vue'
})