2014-01-23 184 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