2

For example when i use the scope i write the template with the scope rules, and the code will be

<div
  class="item ripple"
  v-show="tabList.length > 0"
  :class="{'item-on':currentTabActive==index}"
  v-for="(item,index) in tabList"
  :key="index"
  @click="checkTab(index)"
  >
</div>

but when i use the css modules, i try the code style like

<div :class="[{'$style.red': true},'$style.bold']">hhhhhh</div>

or that

<div :class="{'$style.red': true},'$style.bold'">hhhhhh</div>

or like that

<div :class="{'$style.red': true, '$style.bold'}">hhhhhh</div>

I wonder what's the right way to do?

1
  • How's it been going with your problem? Did you solve your problem? Commented Dec 20, 2019 at 6:50

1 Answer 1

3

Is this what you want? Don't put $style.red inside string '$style.red', instead if you want to interpolate it, use [$style.red]. $style.red works jut like normal javascript variable.

<div 
  v-show="tabList.length > 0" 
  :class="[
    'item', 
    'ripple', 
    {[$style.red]: isRed}, 
    $style.bold, 
    {'item-on': currentTabActive==index}
  ]"
  v-for="(item,index) in tabList" 
  :key="index"
  @click="checkTab(index)">
</div>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.