我是KnockOutJS的新手。我試圖使用在線示例,它工作得很好,並顯示預期的結果,如果我不從HTML調用以下腳本。但是我需要使用這個腳本稍後在瀏覽器上顯示esri地圖。如果我取消註釋下面的腳本,它將不起作用。 如果有人幫我解決我的問題,我將不勝感激。knockoutjs數據綁定與esri腳本不兼容
<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/? v=3.0"/>
這裏是我的代碼,如果你回覆列入腳本的順序
<!DOCTYPE html >
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
<title>Imagery</title>
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.0/js/dojo/dijit/themes/claro/claro.c ss">
<style type="text/css">
html, body { height: 100%; width: 100%; margin: 0; padding: 0; }
#map{padding:0;}
</style>
</head>
<body>
<p data-bind="text: firstName"></p>
<p data-bind="text: lastName"></p>
<input type="text" data-bind="value: firstName" />
<input type="text" data-bind="value: lastName" />
<ul data-bind="foreach: items">
<li><span data-bind="text:firstName"></span></li>
<li><span data-bind="text:lastName"></span></li>
</ul>
<ul data-bind="foreach: items">
<li data-bind="text:name()"></li>
</ul>
</body>
<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/? v=3.0"></script> <!--if I comment this line, it works-->
<script type="text/javascript" src="Scripts/knockout-2.1.0.js"></script>
<script type="text/javascript">
var MyViewModel = function() {
var self = this;
self.firstName = ko.observable("Sravan");
self.lastName = ko.observable("Kumar");
self.items = ko.observableArray([
{ firstName: "A", lastName: "B", name: ko.computed = function() { return "Hello"; }},
{ firstName: "AA", lastName: "BB", name: ko.computed = function() { return "World"; } }
])
};
var viewModel = new MyViewModel();
ko.applyBindings(viewModel);
</script>
</html>
KO綁定的工作:檢查[小提琴](http://jsfiddle.net/fedosov/3pry4/ )。瀏覽器調試控制檯中是否有任何錯誤消息? – fedosov 2012-07-13 07:52:01