JSFiddle - React, Tailwind, and code Playground

by robert chang

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.0.0-rc.4/vue.js"></script>
<div id="app">
  <pcom>
    <soncom msg="Foo" @message="displayChildMsg"></soncom>
    <soncom msg="Bar" @message="displayChildMsg"></soncom>
    <soncom msg="Baz" @message="displayChildMsg"></soncom>
  </pcom>
</div>

Babel + JSX

const Pcom = {
	template: '<div>data from child comp event: {{ edatafromchild }} <slot></slot></div>',
  data: function(){
    return {
       edatafromchild: ''
    }
  },
  methods: {
     displayChildMsg: function(edata){
        this.edatafromchild = edata
     }
  }
}

const Soncom = {
  props: ['msg']  ,
  template: `<div>
  	<button @click="send">Send Message: {{ msg }}</button>
    <slot></slot>
  </div>`,
  methods: {
  	send () {
    	this.$emit('message', this.msg)
    }
  }
}

new Vue({
	el: '#app',
  components: {
  	Pcom,
    Soncom
  }
})