Less-advanced-arguments-@rest-var

提供:Dev Guides
移動先:案内検索

LESSの高度な引数と@rest変数

説明

Mixinは、 …​ を使用して可変個の引数を取ります。 変数名の後に …​ を置くことにより、変数に引数を割り当てることができます。

次のプログラムは、引数を使用する単純な形式を示しています-

.mixin(...) {       //it matches arguments from 0-n
.mixin() {          //it matches exactly 0 arguments
.mixin(@x: 1) {     //it matches arguments from 0-1
.mixin(@x: 1; ...) {//it matches arguments from 0-n
.mixin(@x; ...) {

次のようにコードで @ rest 変数を使用できます-

.mixin(@x; @rest...) {
  //after the variable @a, the @rest is bound to arguments
  //@arguments is bound to all arguments
}