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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.