本文概述
- 参数说明
句法:
model.previous(attribute)
参数说明属性:定义模型的属性。
让我们举个例子。
请参阅以下示例:
<
!DOCTYPE html>
<
head>
<
title>Model Previous Example<
/title>
<
script src="http://img.readke.com/220416/04050M2E-0.jpg" type="text/javascript"><
/script>
<
script src="http://img.readke.com/220416/04050M218-1.jpg" type="text/javascript"><
/script>
<
script src="http://img.readke.com/220416/04050I4U-2.jpg" type="text/javascript"><
/script>
<
/head>
<
body>
<
script type="text/javascript">
var model = new Backbone.Model({
jersey:10, player:'Dhoni'
});
model.set('jersey', '99');
document.write("Value of jersey after set: ", JSON.stringify(model.changedAttributes()));
document.write("<
br>");
document.write("The previous value of jersey is: ", model.previous('jersey'));
<
/script>
<
/body>
<
/html>
【backbone.js模型previous】输出:
将以上代码保存在previous.html文件中,然后在新的浏览器中打开该文件。
文章图片
推荐阅读
- backbone.js集合教程
- backbone.js模型changedattributes
- backbone.js模型isnew
- backbone.js模型haschanged
- backbone.js模型克隆clone
- backbone.js模型解析parse
- backbone.js模型urlroot
- backbone.js模型url
- backbone.js模型isvalid