JSFiddle - React, Tailwind, and code Playground

by Olga Filipova

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.0.3/vue.js"></script>
<!--template for the form-->
<template id="form">
  <div>
    <label for="name">What's your name?</label>
    <input v-bind:value="value" type="text" id="name" v-on:input="onInput">
  </div>
</template>

<!--template for saying hello-->
<template id="hello">
  <h1>{{msg}} {{user}}</h1>
</template>

<!--template for the greetings-->
<template id="greetings">
  <div>
    <form-component v-model="user"></form-component>
    <hello-component :user="user"></hello-component>
  </div>
</template>

<div id="app">
  <greetings-component></greetings-component>
</div>

JavaScript

Vue.component('form-component', {
  template: '#form',
  props: ['value'],
  methods: {
    onInput: function (event) {
      this.$emit('input', event.target.value)
    }
  }
});

Vue.component('hello-component', {
  template: '#hello',
  data: function () {
    return {
      msg: 'Hello'
    }
  },
  props: ['user']
});

Vue.component('greetings-component', {
  template: '#greetings',
  data: function () {
    return {
      user: 'hero'
    }
  }
});

new Vue({
  el: '#app'
});