knockout.js 웹 사이트의 기본 자습서 중 하나를 따랐으므로 이제는 localhost에서 작동하도록 노력하고 있습니다. 머리 부분에는 knockout.js와 misc_form.js의 두 파일이 포함되어 있습니다. knockout.js가 PHP와 함께 작동하는 데 문제가 있습니다
<head>
<script src="/knockout.js"></script>
<script src="/misc_form.js"></script>
</head>
나는 내가 그것을 수정하지 않았기 때문에 misc_form.js에 대한 코드를 생략 할거야 그리고 라이브 knockout.js 튜토리얼에 100 % 작동합니다.
다음은 HTML을
//form.php
function display_form(){
?>
<table>
<thead><tr>
<th>Passenger name</th><th>Meal</th><th>Surcharge</th><th></th>
</tr></thead>
<!-- Todo: Generate table body -->
<tbody data-bind="foreach: seats">
<tr>
<td><input data-bind="value: name" /></td>
<td><select data-bind="options: $root.availableMeals, value: meal, optionsText: 'mealName'"></select></td>
<td data-bind="text: formattedPrice"></td>
<td><a href="#" data-bind="click: $root.removeSeat">Remove</a></td>
</tr>
</tbody>
</table>
<button data-bind="click: addSeat">Reserve another seat</button>
<?
}
편집이다 - 나는 파일의 경로를 변경하고 지금은 그
Uncaught TypeError: Cannot read property 'nodeType' of null //in reference to knockout.js
http : //localhost/misc_form.js로 변경하면 작동하지 않습니다. – user1852176