8
我希望在if語句中定義變量可以在Sass中工作,但不幸的是,我收到錯誤,指出該變量未定義。這裏是我的嘗試:在if語句中聲明的變量導致「未定義的變量」
@for !i from 1 through 9
!foo = #000
@if !i == 1
!bg_color = #009832
@if !i == 2
!bg_color = #195889
...
#bar#{!i}
color: #{!foo}
background-color: #{!bg_color}
有了這個代碼,我會得到以下錯誤:
Undefined variable: "!bg_color".
我確信我試過了。謝謝。 – DEfusion 2009-10-04 17:25:50