JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div id="app">
<div class="parent">
<h1>Parent</h1>
<reusable>
<template slot="clicker" scope="reusable">
<button v-on:click="reusable.onClick">
Close from parent
</button>
<input v-on:input="reusable.onInput">
</template>
</reusable>
</div>
</div>
<script id="reusable" type="x-template">
<div class="reusable">
<h2>Reusable</h2>
<slot name="clicker" v-bind="{ onClick, onInput }">
Default stuff <button v-on:click="onClick">Close</button>
</slot>
<p v-if="clicked">You clicked me</p>
<p v-if="input">You added input to me</p>
</div>
</script>
JavaScript
Vue.component('reusable', {
template: '#reusable',
data() {
return {
clicked: false,
input: false,
}
},
methods: {
onClick() {
this.clicked = true;
console.log('clicked');
},
onInput() {
this.input = true;
console.log('changed');
}
},
})
new Vue({
el: '#app',
})