@aleksejdix
<Card
:title="title"
:image="image"
:body="body"
:url="url"
/>
@aleksejdix
<Card data="card"/>
@aleksejdix
<card :url="url">
<card-title>{{title}}</card-title>
<card-image :src="src" :alt="alt"/>
<card-body>{{ body }}</card-body>
</card>
similar to html
@aleksejdix
LOGIN
Username
Password
YES
YES
OK
SUBSCRIBE
subscribe to our daily newsletter
@aleksejdix
<br />
<hr />
<img />
<nav></nav>
<h1></h1>
<a></a>
self-closing
normal
@aleksejdix
<br />
<hr />
<img />
<nav></nav>
<h1></h1>
<a></a>
void-elements
self closing
normal
@aleksejdix
<my-paragraph :text="text"/>
PARENT
props
slots
scoped slots
attrs
listeners
@aleksejdix
ng-content
children
slot
slot
<dialog>
<slot></slot>
<dialog>
CHILD
<my-component>
<h1>slot</h1>
</my-component>
PARENT
<dialog>
<slot name="header"></slot>
<slot name="body"></slot>
<slot name="footer"></slot>
</dialog>
CHILD
@aleksejdix
<my-modal>
<h1 slot="header">{{title}}</h1>
<img slot="body" src="accordion"/>
<div slot="footer">
<button>ok</button>
</div>
</my-modal>
PARENT
@aleksejdix
<button>
<slot>ok</slot>
</button>
<My-Button>
send
</My-Button>
PARENT
CHILD
@aleksejdix
<button>
<slot name="left"></slot>
<slot>ok</slot>
<slot name="right"></slot>
</button>
<My-Button>
<Icon slot="left"></Icon>
send
</My-Button>
PARENT
CHILD
@aleksejdix
<div
// $slots[name]
v-if="$slots.default"
>
<h1>
<slot></slot>
</h1>
</div>
CHILD
@aleksejdix
@aleksejdix
@aleksejdix
templateRef
render props
scoped slots
nope 😱
props
slots
scoped slots
attrs
listeners
props
slots
scoped slots
attrs
listeners
props
🤯
<slot :text="text"/>
CHILD
<My-Modal>
<template slot-scope="props">
{{ props.text }}
</template>
</My-Modal>
PARENT
<My-Modal>
<template slot-scope="{text}">
{{ text }}
</template>
</My-Component>
PARENT
<template>
<dialog>
<slot
:text="text"
:close="$emit('close')"
></slot>
</dialog>
</template>
CHILD
<My-Modal @close="open = false">
<template slot-scope="{text, close}">
{{ text }}
<button @click="close"></button>
</template>
</My-Modal>
PARENT
@aleksejdix
function updateChildComponent () {
...
if (hasChildren) {
vm.$slots = resolveSlots(
renderChildren,
parentVnode.context
)
vm.$forceUpdate()
}
}
🖖