Bind class to a slot in Vue.js 2

前端 未结 3 1245
有刺的猬
有刺的猬 2020-12-18 20:55

I\'m trying to create a reusable component for iterating over items, filtering them, and adding some classes to the slot (if the item is even, odd, first, last etc..)

<
3条回答
  •  一个人的身影
    2020-12-18 21:25

    With vuejs2 styling from slots has been removed as stated here:

    Content inserted via named no longer preserves the slot attribute. Use a wrapper element to style them, or for advanced use cases, modify the inserted content programmatically using render functions.

    So simplest thing as suggested will be to use a wrapper element as following:

    
    

提交回复
热议问题