2014-04-29 29 views
4

我正在SASS上使用指南針。我已經創建了一些mixin,但是仍然有一個mixin我無法工作。這是用戶選擇的。我知道我可以使用@import「compass/css3/user-interface」導入它;但那不是重點。爲什麼我的'手工'@mixin用戶選擇($ value){..}似乎不起作用?有什麼已知的原因嗎?SASS用戶選擇mixin無需導入 - 指南針

@mixin user-select($value) { 
    -webkit-user-select: $value; 
    -moz-user-select: $value; 
    -ms-user-select: $value; 
    -o-user-select: $value; 
    user-select: $value;  
} 

.myclass { 
    @include user-select(none); 
} 
+0

您使用的用戶,選擇適當的前綴? –

+0

如果你編輯你的問題並添加完整的mixin代碼,這可能會有所幫助。 – pzin

+0

mixin看起來是正確的,所以問題可能在別處。確保你在'@ include'之前定義'@ mixin'。編譯它時會出錯嗎? –

回答

1

似乎爲我工作很好.. 你可以試試這個方法:

@mixin user-select($select) { 
    @each $pre in -webkit-, -moz-, -ms-, -o- { 
    #{$pre + user-select}: #{$select}; 
    } 
    #{user-select}: #{$select}; 
} 

.myclass { 
    @include user-select(none); 
} 
+0

使用Webpack完美地爲我工作。謝謝。 –