LESS 高級參數(shù)和@rest Variable

2018-01-10 11:45 更新

描述

Mixin通過使用 ... 提供可變數(shù)量的參數(shù)。 您可以通過在變量名稱后面放置 ... 為變量賦值參數(shù)。

讓我們看看一些使用參數(shù)的簡單格式如下所示:

.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
}

以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號