Content distribution with slots

Sometimes you want to build a component that can be used to put other elements or components inside it. You may want to build a generic modal dialog component but give the user of your component the ability to write the text of the modal dialog. Alternatively, maybe you want to use a general layout in a component and fill it with other elements. Slots are a way to have a fixed structure in one component and delegate the contents of certain parts of it to the father.

Get Vue.js 2 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.