R
R
Roman Sarvarov2021-07-28 09:17:54
Vue.js
Roman Sarvarov, 2021-07-28 09:17:54

How to pass props to a slot?

I have a component - a button with an icon.

<button>
<slot name="icon" />
<slot />
</button>


There was a need to insert an icon after the text with the button.
Is there a more concise way to do this without adding a new slot? But I don't like this one very much:
<button>
<slot name="icon" />
<slot />
<slot name="right-icon" />
</button>


Something like:
<AppButton>
<template #icon align="right">
<i class="icon"></i>
</template>
button text
</AppButton>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WapSter, 2021-07-28
@wapster92

https://ru.vuejs.org/v2/guide/components-slots.htm...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question