1. Old Style
var array = [];
var Vmdoel = avalon.define ("id", function (VM) {
VM.AA = "AAA",
VM.BB = "BBB",
Array.push (10),
Avalon.mix (VM, {aa:2,cc:3});
Vm.fun = function () {
}
});
2. New Style
var Vmodel = Avalon.define ({
$id: ID,
AA:AAA,
bb:bbb
})
Vmodel. $watch ("AA", callback)
3, new and old style contrast
(1) distinguish between VMS and VMODEL,VM can only define attributes, Vmodel can only update the properties inside or the method of executing it
(2) Array.push (10), will be executed twice
(3) avalon.mix () repeat definition in ie6-8
4, Ie6-8 repeat definition
Cause under Ie6-8, the naming rules for generating vmodel,vbscript variables using VBScript are:
* Variable names can only be composed of letters, numbers and down lines;
* The first letter of a variable name must be an English letter;
* The valid character length of the variable name is 255;
* You cannot use VBScript's reserved words (keywords) as variable names, but you can put reserved words in the name of the person variable.
VBScript does not differentiate between variable names and the case of letters in other names, Hello, hello, and hello refer to the same name, that is, when a variable is defined, the same character, regardless of the same case, refers to the variable.
Workaround do not declare variables in Vmodel initialization that differ only in case. For readability, it is recommended to use the naming conventions for small humps to name variables. var vm = Avalon.define ({$id: "demo", FirstName: "}");
Avalon define new and old style contrast