Vaseem Akram
Vaseem Akram

Reputation: 69

What is the various uses of slots in VUE.js

Could someone let me know what is the various ways of using slots in Vue.js until now I think slots could be used to pass data from child component to parent component to render HTML content? could slots be used to call the parent component methods?

Upvotes: 0

Views: 52

Answers (2)

vitoboski
vitoboski

Reputation: 223

Slots in Vue.js allow us to receive HTML content, witch also may be using Vue feature, from outside of the component. Basically just like props, but where props are for data, which component needs, slots are meant to be used for HTML code, for the template code components needs.

Upvotes: 1

Michael
Michael

Reputation: 5048

The short answer to your question is yes, slots exist in the parent scope and can expose data, functions and some other stuff from the child scope to the parent scope. As well as utilize anything within the parent scope.

Upvotes: 1

Related Questions