sample code block


 s

// Parent component
<template>
  <child-component v-on:message="handleMessage"></child-component>
</template>
<script>
  import ChildComponent from './ChildComponent.vue'
  export default {
    components: { ChildComponent },
    methods: {
      handleMessage(message) {
        console.log(message)
      }
    }
  }
</script>

// Child component
<template>
  <button v-on:click="sendMessage">Send message</button>
</template>
<script>
  export default {
    methods: {
      sendMessage() {
        this.$emit('message', 'Hello from child')
      }
    }
  }
</script>

s


 s

// Parent component
<template>
  <child-component v-on:message="handleMessage"></child-component>
</template>
<script>
  import ChildComponent from './ChildComponent.vue'
  export default {
    components: { ChildComponent },
    methods: {
      handleMessage(message) {
        console.log(message)
      }
    }
  }
</script>

// Child component
<template>
  <button v-on:click="sendMessage">Send message</button>
</template>
<script>
  export default {
    methods: {
      sendMessage() {
        this.$emit('message', 'Hello from child')
      }
    }
  }
</script>

s


 s

// Parent component
<template>
  <child-component v-on:message="handleMessage"></child-component>
</template>
<script>
  import ChildComponent from './ChildComponent.vue'
  export default {
    components: { ChildComponent },
    methods: {
      handleMessage(message) {
        console.log(message)
      }
    }
  }
</script>

// Child component
<template>
  <button v-on:click="sendMessage">Send message</button>
</template>
<script>
  export default {
    methods: {
      sendMessage() {
        this.$emit('message', 'Hello from child')
      }
    }
  }
</script>

s


 s

// Parent component
<template>
  <child-component v-on:message="handleMessage"></child-component>
</template>
<script>
  import ChildComponent from './ChildComponent.vue'
  export default {
    components: { ChildComponent },
    methods: {
      handleMessage(message) {
        console.log(message)
      }
    }
  }
</script>

// Child component
<template>
  <button v-on:click="sendMessage">Send message</button>
</template>
<script>
  export default {
    methods: {
      sendMessage() {
        this.$emit('message', 'Hello from child')
      }
    }
  }
</script>

s


 s

// Parent component
<template>
  <child-component v-on:message="handleMessage"></child-component>
</template>
<script>
  import ChildComponent from './ChildComponent.vue'
  export default {
    components: { ChildComponent },
    methods: {
      handleMessage(message) {
        console.log(message)
      }
    }
  }
</script>

// Child component
<template>
  <button v-on:click="sendMessage">Send message</button>
</template>
<script>
  export default {
    methods: {
      sendMessage() {
        this.$emit('message', 'Hello from child')
      }
    }
  }
</script>

s


 s

// Parent component
<template>
  <child-component v-on:message="handleMessage"></child-component>
</template>
<script>
  import ChildComponent from './ChildComponent.vue'
  export default {
    components: { ChildComponent },
    methods: {
      handleMessage(message) {
        console.log(message)
      }
    }
  }
</script>

// Child component
<template>
  <button v-on:click="sendMessage">Send message</button>
</template>
<script>
  export default {
    methods: {
      sendMessage() {
        this.$emit('message', 'Hello from child')
      }
    }
  }
</script>

s


 s

// Parent component
<template>
  <child-component v-on:message="handleMessage"></child-component>
</template>
<script>
  import ChildComponent from './ChildComponent.vue'
  export default {
    components: { ChildComponent },
    methods: {
      handleMessage(message) {
        console.log(message)
      }
    }
  }
</script>

// Child component
<template>
  <button v-on:click="sendMessage">Send message</button>
</template>
<script>
  export default {
    methods: {
      sendMessage() {
        this.$emit('message', 'Hello from child')
      }
    }
  }
</script>

s



// Parent component
<template>
  <child-component v-on:message="handleMessage"></child-component>
</template>
<script>
  import ChildComponent from './ChildComponent.vue'
  export default {
    components: { ChildComponent },
    methods: {
      handleMessage(message) {
        console.log(message)
      }
    }
  }
</script>

// Child component
<template>
  <button v-on:click="sendMessage">Send message</button>
</template>
<script>
  export default {
    methods: {
      sendMessage() {
        this.$emit('message', 'Hello from child')
      }
    }
  }
</script>

s


 s

// Parent component
<template>
  <child-component v-on:message="handleMessage"></child-component>
</template>
<script>
  import ChildComponent from './ChildComponent.vue'
  export default {
    components: { ChildComponent },
    methods: {
      handleMessage(message) {
        console.log(message)
      }
    }
  }
</script>

// Child component
<template>
  <button v-on:click="sendMessage">Send message</button>
</template>
<script>
  export default {
    methods: {
      sendMessage() {
        this.$emit('message', 'Hello from child')
      }
    }
  }
</script>

s


 s

// Parent component
<template>
  <child-component v-on:message="handleMessage"></child-component>
</template>
<script>
  import ChildComponent from './ChildComponent.vue'
  export default {
    components: { ChildComponent },
    methods: {
      handleMessage(message) {
        console.log(message)
      }
    }
  }
</script>

// Child component
<template>
  <button v-on:click="sendMessage">Send message</button>
</template>
<script>
  export default {
    methods: {
      sendMessage() {
        this.$emit('message', 'Hello from child')
      }
    }
  }
</script>

s


 s

// Parent component
<template>
  <child-component v-on:message="handleMessage"></child-component>
</template>
<script>
  import ChildComponent from './ChildComponent.vue'
  export default {
    components: { ChildComponent },
    methods: {
      handleMessage(message) {
        console.log(message)
      }
    }
  }
</script>

// Child component
<template>
  <button v-on:click="sendMessage">Send message</button>
</template>
<script>
  export default {
    methods: {
      sendMessage() {
        this.$emit('message', 'Hello from child')
      }
    }
  }
</script>

s


 s

// Parent component
<template>
  <child-component v-on:message="handleMessage"></child-component>
</template>
<script>
  import ChildComponent from './ChildComponent.vue'
  export default {
    components: { ChildComponent },
    methods: {
      handleMessage(message) {
        console.log(message)
      }
    }
  }
</script>

// Child component
<template>
  <button v-on:click="sendMessage">Send message</button>
</template>
<script>
  export default {
    methods: {
      sendMessage() {
        this.$emit('message', 'Hello from child')
      }
    }
  }
</script>

s


 s

// Parent component
<template>
  <child-component v-on:message="handleMessage"></child-component>
</template>
<script>
  import ChildComponent from './ChildComponent.vue'
  export default {
    components: { ChildComponent },
    methods: {
      handleMessage(message) {
        console.log(message)
      }
    }
  }
</script>

// Child component
<template>
  <button v-on:click="sendMessage">Send message</button>
</template>
<script>
  export default {
    methods: {
      sendMessage() {
        this.$emit('message', 'Hello from child')
      }
    }
  }
</script>

s


 s

// Parent component
<template>
  <child-component v-on:message="handleMessage"></child-component>
</template>
<script>
  import ChildComponent from './ChildComponent.vue'
  export default {
    components: { ChildComponent },
    methods: {
      handleMessage(message) {
        console.log(message)
      }
    }
  }
</script>

// Child component
<template>
  <button v-on:click="sendMessage">Send message</button>
</template>
<script>
  export default {
    methods: {
      sendMessage() {
        this.$emit('message', 'Hello from child')
      }
    }
  }
</script>

s

No comments:

Post a Comment

Event listening in react

 How we can listen to som eevents some envents fire like click or automatically user enters into input button , that is event on word type i...