VueJS - v-bind:style + hover

后端 未结 6 2069
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-01 12:27

I need to use CSS hover with VueJS v-bind:style directive but couldn\'t find information regarding it.

I need to bind styles for hover but v-bind:style.hover=

6条回答
  •  星月不相逢
    2021-01-01 12:48

    Other way (using css variables).

    You need create HTML with style

    
    

    and inject it into your component.

    
    

    Then simply use this variable in static css file to setup button style.

    button:hover { background: var(--btn-hover); }
    

    Note: you can describe default variable value in :root selector.

提交回复
热议问题