-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path18-componentes-slots-scopes.html
60 lines (51 loc) · 1.92 KB
/
18-componentes-slots-scopes.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Vue.js</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.2/css/bulma.min.css">
</head>
<body>
<section class="section">
<div class="container">
<main>
<h1 class="is-size-1">Scopes con templates y slots</h1>
<!--
1. Se asignan los datos directamente de usuarios al listado que es props
2. Se va el template a utilizar los datos
3. Regresar a <xusuario> a renderizar lo del slot
4. Se sutituye los datos pasados como props del scope y definido con la variable temporal
-->
<xusuario :listado="usuarios">
<template slot="user-slot" scope="tempdata">
<li>{{tempdata.namex}}</li>
</template>
</xusuario>
<xusuario :listado="usuarios">
<template slot="user-slot" scope="tempdata">
<li><strong>{{tempdata.namex}}</strong></li>
</template>
</xusuario>
<xusuario :listado="usuarios">
<template slot="user-slot" scope="tempdata">
<li><i>{{tempdata.namex}}</i></li>
</template>
</xusuario>
</main>
</div>
<!--<slot name="tarea" v-for="tarea in listado" :title="tarea.nombre"></slot> -->
<!--<li v-for="t in listado">{{t.nombre}}</li> -->
<template id="plantilla-usuario">
<ul>
<slot name="user-slot" v-for="user in listado" :namex="user.nombre"></slot>
</ul>
</template>
</section>
<script src="https://unpkg.com/[email protected]/dist/vue.js"></script>
<script defer src="https://use.fontawesome.com/releases/v5.3.1/js/all.js"></script>
<script src="18-main.js"></script>
</body>
</html>