을 내 작품에 대해 패키지로 적습니다. 이 같은공백이나 따옴표를 덜 수정하여 임의의 키 프레임 이름을 만드는 방법
일부 코드 :
.goTop(@time:1s,@position:-100%){
\t @random_suffix:`Math.round(Math.random() * 1.0e8)`;
\t @keyframes @random_suffix{
\t \t from{transform:translateY(0);}
\t \t to{transform:translateY(@position);}
\t }
\t animation-name:@random_suffix;
\t animation-duration:@time;
\t animation-timing-function:ease-out;
\t animation-fill-mode:forwards;
}
:
.testbox{
.goTop(1s);
}
왜 내가 임의의 숫자를 사용해야합니까?
, 때문에 모든 키 프레임은 같은 이름, 그리고 마지막 부분은 오래된 부분을 덮어 쓰게됩니다. (인수가 동일하지 않습니다)
지금, 키 프레임 이름은 임의의 숫자 인 경우.
그러나 키 프레임 이름이 숫자 인 경우 애니메이션이 실행되지 않습니다.
goTop_12345678과 같은 이름으로 바란다.
변수 이름의 문자열에 문의하려고합니다. 그래서
@temp1:goTop_;
@temp2:`Math.round(Math.random() * 1.0e8)`;
@test:@temp1 + @temp2;
// Error
//{"type":"Syntax","message":"Cannot read property 'numerator' of undefined","filename":"input","index":94,"line":4,"callLine":null,"column":0,"extract":["@temp2:goTop_;","@test:@temp1 + @temp2;",""]}
@temp1:'goTop_';
@temp2:`Math.round(Math.random() * 1.0e8)`;
@test:`@{temp1} + @{temp2}`;
//"goTop_12345678"
//It contains the symbol quote "",and the animation will not run.
@temp1:goTop_;
@temp2:@temp1+`Math.round(Math.random() * 1.0e8)`;
@test:@temp2;
//"goTop_ 12345678"
//It contains the space ,and the animation will not run too.
//For the second and third way
//I have try to use replace way to solve it,but I failed.
고마워요. @ 일곱 단계 - 최대에 대한
@cloudhead
문제는 기본적으로 "이하의 문자열을 연결하는 방법"을 참조하십시오. [예] (http://less2css.org/#%7B%22less%22%3A%22%5Cnfoo%20%7B%5Cn%5Ct.go-top() % 3B % 20 % 20 % 5Cn % 7D % 5Cn % 5Cn.go-top() % 20 % 7B % 5Cn % 5Ct % 40Nrandom % 3A % 20 % 60Math.round (Math.random() % 20 * % 201.0e8) % 60 % 3B % 5Cn % 20 % 20 % 20 % 20 % 40 % % 3A % 20 % % 5C % 22go-top- % 40 % 7Brandom % 7D % 5C % 22 % 3B % 20 % 2F % 2F % 20 % 3C- % 20here % 20we % 20go % 5Cn % 5Ct % 40 키 프레임 % 20 % 40 % 20 % 7B % 5Cn % 5Ct % 5Ctfrom % 20 % 7Bbar % 20 % 3A1 % 7D % 5Cn % 5Ct % 5Ctto % 20 % 20 % 20 % 7Bbaz % 3A % 202 % 7D % 5Cn % 5Ct % 7D % 5Cn % 5Ctanimation-name % 3A % 20 % 40name % 3B % 5Cn % 7D % 5Cn % 22 % 7D). –
구체적인 경우에는 [just ...] (http://less2css.org/#%7B%22less%22%3A%22%5Cnfoo%20%7B%5Cn%5Ct.go-top) % 3B % 20 % 20 % 5Cn % 7D % 5Cn % 5Cn.go-top() % 20 % 7B % 5Cn % 5Ct % 40 % % 3A % 20 % % 60'go-top '% 20 % 2B % 20Math. round (Math.random() % 20 * % 201.0e8) % 60 % 3B % 5Cn % 5Ct % 40 키 프레임 % 20 % 40 % 20 % 7B % 5Cn % 5Ct % 5Ctfrom % 20 % 7Bbar % 20 % 3A1 % 7D % 5Cn % 5Ct % 5Ctto % 20 % 20 % 20 % 7Bbaz % 3A % 202 % 7D % 5Cn % 5Ct % 7D % 5Cn % 5Ctanimation-name % 3A % 20 % 40 % % 3B % 5Cn % 7D % 5Cn % 22 % 7D). 일반적으로 그들은 일반적으로 무작위적인 hackery 대신에 mixin arg로 이름을 붙이기도합니다 (그냥 휴 ...). –
고맙습니다. 당신 말이 맞습니다. – iRuxu