Bind class to a slot in Vue.js 2

前端 未结 3 1226
有刺的猬
有刺的猬 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:24

    I have another way can get your aim, but not use render, still use slot.

    The reusable component:

    
    
    
    

    use _class to class keyword, so Vue.js will let _class as the common property.

    Then in your use:

    
      
    
    

    By the scope property, your can still get _class from slot.

    After all, use render may be more conciseness. :)

提交回复
热议问题