루프의 조건을 평가하지 않으려 고 올바른 처리를 반환하는 함수를 작성한 다음 해당 변수를 사용하는 방법을 생각했습니다. 루프에조건에 변수에 함수를 동적으로 할당하고 typescript 루프에서 사용 2.3.4
은 기본적 아이디어는 외모와 같은 :
export class myClass{
ref;
Treatment1(){code}
Treatment2(){code}
Treatment3(){code}
selectTreatment(){
if(condition1){
ref = Treatment1()
else if(condition2){
ref = Treatment2()
else (condition3){
ref = Treatment3()
}
executeTreatment(){
setInterval(ref(),300)
}
}
잘 모르겠지만 "이"핵심어에 문제가 있다고 생각합니다!
나는이 같은 솔루션 자금을 가지고
export class myClass{
ref:any;
Treatment1(){code}
Treatment2(){code}
Treatment3(){code}
selectTreatment():Function{
if(condition1){
return()=>{Treatment1()};
else if(condition2){
return()=>{Treatment1()};
else (condition3){
return()=>{Treatment1()};
}
executeTreatment(){
this.ref=this.selectTreatement();
setInterval(ref(),300);
}
}
하지 clear.You처럼 뭔가에
selectTreatment
할당을 변경하려는 것은 더'code' 및 세부 사항을 제공해야합니다. – Sampath저는 typescript가 새롭고 프로젝트가 비공개입니다! 그냥 인내심을 갖고 무엇이 분명한 지 알려주고 회신 해 주실 것을 당부하십시오. –
위의'code' 만 볼 수 있다면 다른 사람에게 해결책을 줄 수 있습니까? 당신은 관련된 모든'code'를 보여줄 필요가 있습니다.'code' 위에'this'을 사용한 곳은 어디입니까? – Sampath