[Vuejs]-How efficient is `slot-scope` over `v-for`?

3👍

slot-scopes and slots in general are totally different to v-for.

v-for is used to create a loop bound to a collection.

slot is used to pass DOM elements/data to a component.

slot-scope is used to pass component data to the underlying components – here’s an example:

<json-get url="/api/v1/users">
    <template slot-scope="data">
        <ul>
            <li v-for="user in data.results">{{ user.name }}</li>
        </ul>
    </template>
</json-get>

slot-scope="data" passes info contained within ‘data’ for use of the nested DOM elements.

Leave a comment