Listening to events that have been triggered by child components

Listening to events that have been emitted by children components is done using the v-on directive and, just like with Angular, you can also pass data along. Here's an example:

<!DOCTYPE html> 
<html lang="en"> 
<head> 
    <meta charset="UTF-8"> 
    <title>Todo task list listen</title> 
 
    <!-- development version of Vue.js --> 
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> 
 
    <style> 
        .todoTask { 
            cursor: pointer; 
        } 
        .todoTask:hover { 
            background-color: #1e9; 
        } 
    </style> 
</head>

In the head tag, we define some styles for our example and, as usual, we define the logic for our example in the body tag:

<body> <div id="app"> <todo-list v-bind:items="todos"></todo-list> </div> <script ...

Get Learn TypeScript 3 by Building Web Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.