2014-01-23 186 views
-1

寫這個的正確方法是什麼?Sass:將默認值設置爲變量

@mixin image-bg($bg-url, $full-page: false) 
    background-repeat: no-repeat 
    background-position: center 
    background-image: asset-url($bg-url) 
    background-attachment: fixed 
    @if $fullpage 
    -webkit-background-size: cover 
    -moz-background-size: cover 
    -o-background-size: cover 
    background-size: cover 

我想將$ full-page變量傳遞給@mixin。當用戶將$ full-page設置爲true時,它將使用cover語句。如果沒有給予或設置爲false,也不會使用cover語句

回答

1

您的代碼看起來正確,除了一個小錯誤:

@if $fullpage 

你的變量命名爲$full-page,不$fullpage