我复制了一个 knockoutjs 示例:
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/knockout/2.2.0/knockout-min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<h2>Participants</h2>
Here are the participants:
<div data-bind="template: { name: 'person-template', data: buyer }"></div>
<div data-bind="template: { name: 'person-template', data: seller }"></div>
<script id="person-template" type="text/html">
<h3 data-bind="text: name"></h3>
<p>Credits: <span data-bind="text: credits"></span></p>
</script>
<script type="text/javascript">
function MyViewModel() {
this.buyer = { name: 'Franklin', credits: 250 };
this.seller = { name: 'Mario', credits: 5800 };
}
ko.applyBindings(new MyViewModel());
</script>
</html>
当我将 jQuery 更新到版本 1.9时,出现以下错误:
Uncaught TypeError: Object function (e,t){return new st.fn.init(e,t,X)} has no method 'clean'
如果有人能解释错误是在 jQuery 还是 KO 中,我将不胜感激。