Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
214 views
in Technique[技术] by (71.8m points)

LESS - Reassign of variable value inside a loop?

Does anyone know if it's possible to reassign a variable value inside a loop in LESS ???

I'm trying to exit a loop by reassiging the @extend-grid-breakpoint variable to false...

Thanks!!!

.tst-container,
.tst-container-fluid {
  .set-container();
}

each(.tst-container-max-widths(), .(@container-max-width-value, @container-max-width-name) {
  .tst-container-@{container-max-width-name} {
    &:extend(.tst-container-fluid);
  }

   @media (min-width: .tst-grid-breakpoints[$@container-max-width-name]) {
    .tst-container {
      max-width: @container-max-width-value;
    }
    
    /* 
     * setting the variable as true
     */
    @extend-grid-breakpoint: true;
    
    each(.tst-grid-breakpoints(), .(@grid-breakpoint-value, @grid-breakpoint-name) {
      & when (@extend-grid-breakpoint) {
        .tst-container-@{grid-breakpoint-name} {
          &:extend(.tst-container);
        }

        /* 
         * I want to exit the loop by reassigning false to the variable
         */
        & when (@container-max-width-name = @grid-breakpoint-name) {
           @extend-grid-breakpoint: false;
        }
      }
    });
  }
});

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...