less / less.js

Less. The dynamic stylesheet language.
http://lesscss.org
Apache License 2.0
17k stars 3.41k forks source link

help | how to use(or possibility to) mixin with function? #3617

Open orlowang opened 3 years ago

orlowang commented 3 years ago

in my case first I use function to create a .in-10 ...

@selectors: 5, 10, 20;
each(@selectors, {
    .in-@{value}{
        padding: (@value)px;
    }
});

then use .in-10 as a mixin to .button

.button{
    .background-color:  green;
    .in-10();  /* <--  here to use mixin */
    ...some other
}

an error say .in-10 is undefined, may I think they are output same time so that .in-10 is not find, how can I make this work? how to code less in this case?

I can't got any answer in stackoverflow so I try here, pls help!

iChenLei commented 3 years ago

emmm, write seprate .in-5 / .in-10 / in-20 mixin.