2014-11-21 65 views
0

我今天更新SASS使用版本3.4.7不幸的是,自從我的項目開始以來,我使用的一個mixin不再工作。我不明白爲什麼...用SASS 3.4.7更新主題的mixin

$program: test1; 

@mixin program($programName) { 
    @each $p in $programName { 
    @if $p == $program { 
     @content; 
    } 
    } 
} 

$cta-box-type: null !default; 

@include program(test1) { 
    $cta-box-type: cta-buy, cta-like; 
} 

@include program(test2) { 
    $cta-box-type: cta-like, cta-share; 
} 

@each $cta-type in $cta-box-type { 
    .banner--#{$cta-type} .banner { 
     background: white image-url("Modules/Cta/bg-#{$cta-type}-1.jpg") no-repeat bottom left; 
     background-size: 100% auto; 
    } 
} 

DEMO SASSMEISTER

編譯後的結果是這樣的:

.banner-- .banner { 
    background: white url('/images/Modules/Cta/bg--1.jpg') no-repeat bottom left; 
    background-size: 100% auto; 
} 

相反的:

.banner--cta-buy .banner { 
    background: white url('/images/Modules/Cta/bg-cta-buy-1.jpg') no-repeat bottom left; 
    background-size: 100% auto; 
} 

.banner--cta-like .banner { 
    background: white url('/images/Modules/Cta/bg-cta-like-1.jpg') no-repeat bottom left; 
    background-size: 100% auto; 
} 

如果有人有一個想法爲什麼它沒有更多的工作,它已經幫了我很多! 謝謝!

+0

的可能重複[爲什麼青菜失敗的咕嚕命令錯誤編譯「指數是2,但名單隻有1項長\'第n個'」?](http://stackoverflow.com/questions/26637848/why-does-sass-fail-to-compile-with-grunt-command-error-of-index-is-2-but-list-i) – cimmanon 2014-11-21 12:50:42

+0

謝謝@cimmanon,你的鏈接幫我找到了一個解決方案。 – 2014-11-21 13:13:21

回答

0

我找到了解決辦法:

我只是刪除默認,並添加全球!。

$cta-box-type: null; 

@include program(test1) { 
    $cta-box-type: cta-buy, cta-like !global; 
} 

@include program(test2) { 
    $cta-box-type: cta-like, cta-share !global; 
}