-3
녹아웃 API를 배우기 시작했습니다. 나는이 간단한 코드를 작성했는데, 이는 매우 간단하지만 작동하지 않습니다. 밖으로배열 작업
<h4>People(<span data-bind="text: controls().length"> </span>)</h4>
<ul data-bind="foreach:controls">
<li>
Id: <span data-bind="text: controls.id"></span>
</li>
</ul>
<button data-bind="click:$root.addControls">Add</button>
var Form = function(){
this.controls = [{id:"T1",type:"TextInput"},
{id:"T2",type:"TextInput"}];
this.addControls = function(){
this.controls.push({id:"",type:""})
};
}
var Controls = function(id,type){
this.id = id;
this.type = type;
}
ko.applyBindings(new Form());
"작동하지 않음"을 정의하십시오. – ThiefMaster
예상되는 결과가 나타나지 않습니다. 당신은 코드 – Rakesh
을 확인할 수 있습니다. 코드에는 객체 리터럴에서':'대신'='를 사용하고 객체 리터럴 주위에서'{}'를 잊어 버린 것과 같은 구문 오류가 있습니다. – ThiefMaster