混入採用可變數量的參數可使用... 。可以通過放置...變數名後分配參數變數。
讓我們來看看一些簡單的格式使用參數如下圖所示:
.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 }
上一篇:
Less @arguments變數
下一篇:
Less模式匹配