如何在Vue中有条件地使用CSS类

html-css010

如何在Vue中有条件地使用CSS类,第1张

<a  v-bind:class="index==0?'current1':'current2'" >test</a>

上面代码 index请在data里面定义

如图是一个常见的vue文件结构

在app.html 或者*.vue中引入css,如下所示:

在 app.html引入css对阵个页面都生效,在vue文件中引入,只对改vue生成的页面有效