Как проверить двойной v-for и если есть в обоих, изменить стиль - PullRequest
1 голос
/ 06 октября 2019
<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>

Это не работает, как я ожидаю, показывая мне все, как это. В основном красного цвета, некоторые из них зеленого цвета. Это повторяется много времени. Я пробовал также с v-Once, но это не сработало.

 Membership of club 2001
Membership of club 2002
Membership of club 2003
Membership of club 2004
Membership of club 2006
Membership of club 2007
Membership of club 2009
Membership of club 2010
Membership of club 2012
Membership of club 2013
Membership of club 2014
Membership of club 2015
Membership of club 2017
Membership of club 2018
Membership of club 2019
Membership of club 2020
Membership of club 2001
Membership of club 2002
Membership of club 2003
Membership of club 2004
Membership of club 2006
Membership of club 2007
Membership of club 2009
Membership of club 2010
Membership of club 2012
Membership of club 2013
Membership of club 2014
Membership of club 2015
Membership of club 2017
Membership of club 2018
Membership of club 2019
Membership of club 2020
Membership of club 2001
Membership of club 2002
Membership of club 2003
Membership of club 2004
Membership of club 2006
Membership of club 2007
Membership of club 2009
Membership of club 2010
Membership of club 2012
Membership of club 2013
Membership of club 2014
Membership of club 2015
Membership of club 2017
Membership of club 2018
Membership of club 2019
Membership of club 2020
Membership of club 2001
Membership of club 2002
Membership of club 2003
Membership of club 2004
Membership of club 2006
Membership of club 2007
Membership of club 2009
Membership of club 2010
Membership of club 2012
Membership of club 2013
Membership of club 2014
Membership of club 2015
Membership of club 2017
Membership of club 2018
Membership of club 2019
Membership of club 2020
Membership of club 2001
Membership of club 2002
Membership of club 2003
Membership of club 2004
Membership of club 2006
Membership of club 2007
Membership of club 2009
Membership of club 2010
Membership of club 2012
Membership of club 2013
Membership of club 2014
Membership of club 2015
Membership of club 2017
Membership of club 2018
Membership of club 2019
Membership of club 2020
Membership of club 2001
Membership of club 2002
Membership of club 2003
Membership of club 2004
Membership of club 2006
Membership of club 2007
Membership of club 2009
Membership of club 2010
Membership of club 2012
Membership of club 2013
Membership of club 2014
Membership of club 2015
Membership of club 2017
Membership of club 2018
Membership of club 2019
Membership of club 2020
Membership of club 2001
Membership of club 2002
Membership of club 2003
Membership of club 2004
Membership of club 2006
Membership of club 2007
Membership of club 2009
Membership of club 2010
Membership of club 2012
Membership of club 2013
Membership of club 2014
Membership of club 2015
Membership of club 2017
Membership of club 2018
Membership of club 2019
Membership of club 2020

Как мне показать все членства и только те членства, в которых они участвуют, должны быть зеленого цвета? Все остальные должны окрашиваться в красный цвет ...

1 Ответ

0 голосов
/ 06 октября 2019

<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>

можешь попробовать вот так

...