如何检查double v-for,如果两者都存在,则更改样式

时间:2019-10-06 13:10:23

标签: javascript vue.js styles v-for

import ch.qos.logback.classic.{Level, LoggerContext}
import scala.language.postfixOps
import io.gatling.core.Predef._
import org.slf4j.LoggerFactory   
import scala.concurrent.duration._

class TestSimulation extends TestRestScenario {

      val context: LoggerContext = LoggerFactory.getILoggerFactory.asInstanceOf[LoggerContext]
      context.getLogger("io.gatling.http").setLevel(Level.valueOf("DEBUG"))

  setUp(scenario.inject(rampConcurrentUsers(1) to (Config.numberOfUsers) during (Config.rampUpDuration minutes)))
    .protocols(httpconf).maxDuration((Config.scenarioDuration minutes))
    .assertions(global.successfulRequests.percent.is(100))
}

这不符合我的预期,向我显示了所有类似内容。大多数为红色,有些为绿色。它重复很多时间。我也尝试过v-once,但是没有用。

<div v-for="memberMembershipyear in memberMembershipyears">
  <li v-for="membershipYear in membershipYears"
      :style="membershipYear.num === memberMembershipyear.num ? 'color:green' : color:red'">
         {{membershipYear.membershipType}} {{membershipYear.yr}}
  </li>
</div>

我如何显示所有成员身份,而仅显示应成为绿色的成员身份?所有其他颜色都应该变成红色...

1 个答案:

答案 0 :(得分:0)


<div v-for="memberMembershipyear in memberMembershipyears">
  <li v-for="membershipYear in membershipYears"
      :style="membershipYear.num === memberMembershipyear.num ? 'color:green' : 'color:red'">
         {{membershipYear.membershipType}} {{membershipYear.yr}}
  </li>
</div>

你可以那样尝试