【问题标题】:how do you add an active class to a particular div如何将活动类添加到特定 div
【发布时间】:2019-07-02 16:26:46
【问题描述】:
<newsfeed-view inline-template :newsfeed="{{  $feed }}">
    <article class="bg-white p-8 w-1/2 mt-4 p-4" id="newsfeedPost" v-bind:class="{ 'active' : isHighlighted } ">
        <h3>
            <a href="#" class="text-blue-dark hover:no-underline hover:text-black active:no-underline active:text-4xl" @click="this.isHighlighted = true">{{  $feed->newsfeed_title }}</a>
        </h3>
        <p class="mt-4">{{ $feed->body }}</p>
    </article>
</newsfeed-view>

这是我的风格部分

<style lang="scss" scoped>
.highlighted { 
    @apply .border-l-4 .border-orange ;
}

#newsfeedPost { 
    @apply .rounded-lg ; 
}


</style>

如果我单击该锚标记,我想添加突出显示的类..

【问题讨论】:

    标签: vuejs2 tailwind-css


    【解决方案1】:

    您的v-bind:class="{ 'active' : isHighlighted }" 行将切换active 类。如果您想按照样式表中的指示切换 highlighted 类,请使用:

    v-bind:class="{ 'highlighted' : isHighlighted }"
    

    【讨论】:

      猜你喜欢
      • 2012-04-06
      • 1970-01-01
      • 1970-01-01
      • 2022-12-03
      • 2018-11-09
      • 2018-05-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多