Avalon define new and old style contrast

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.