Summary of avalon binding properties in JavaScript
avalon is a front-end MVVM framework that completely divides all front-end code into two parts. View processing is implemented through binding (angular has a cooler term called instructions), and business logic is concentrated in objects called VMs. As long as we operate on the VM's data, it will be automatically and magically synchronized to the view.
$model (all non-$attributes), $event (event object)
1. Scope delimitation
ms-controller: scan the DOM tree from bottom to top according to the principle of proximity
ms-important: scan only this The node and below are used as the scanning area
ms-skip: invalidate the binding
2. ms-duplex two-way binding attribute: In addition to binding (VM synchronizes data to V) data to the DOM node, it will also secretly add data to the node Bind a listening event to it, and when the node data changes, synchronize the data in V to the VM in time
(1) text, password, textarea requires the binding value to be a string (ms-duplex-text)
(2)radio: bound to boolean (ms-duplex-boolean)
(3)checkbox: bound to array (ms-duplex-string)
(4)select: bound to string or array ( ms-duplex-string)
is followed by the ms-duplex2.0 binding attribute
3. ms-visible: similar to toggle, the expression is displayed when true, and is displayed or hidden by setting the display to block or none
4. Insertion and removal processing ms-if: add node elements to display elements, set comment to hide nodes (delete nodes)
5. Data cache ms-data-*, save objects or arrays Use ms-data (bound to the DOM node object instead of as an attribute), save it on the node, process the return when displayed, and bind it as data-* attribute
6. Attribute operation ms-class (class), ms- duplex(value),ms-attr,ms-href,ms-src
boolean attributes: ms-attr-disabled,ms-attr-readonly,ms-attr-selected,ms-attr-checked
String inherent attributes :ms-attr-id,ms-attr-name,ms-attr-title,ms-src,ms-href
Custom attributes: ms-attr-data-url, ms-attr-data-id
ms-class: ms-class='active' ms-class='active:isOk'
ms-active,ms-hover
7, ms-duplex2.0
ms-duplex-string,ms-duplex-number,ms-duplex-checked,ms-duplex-boolean,ms-data-duplex
auxiliary data-duplex-focus ,data-duplex-changed,data-duplex-event
8. Style operation: ms-css (inline), ms-class (external introduction)
<button ms-click="toggle" ms-css-width="100">显示</button> <span ms-if="flag">{{message}}</span>
9. Event binding: ms-on -eventName,ms-eventName
ms-mouseenter, ms-mouseleave (only applies to selected elements), ms-input (ms-on-input), the order of multi-event binding has nothing to do with natural numbers, but is related to the order of events
10. Loop operation
ms-each-traverse temporary variables (bound on the parent element)
ms-repeat-traverse temporary variables (bind on child elements)
ms-with-traverse temporary variables ( Bind on the parent element)
Array: el default temporary variable, $index the index of the current element, whether $first is the first element boolean, $last, $remove returns a function to delete the current element, $outer inner layer Loop outer loop variable
Hash (object): $key key name, $val key value, $outer ($outer.$index)
<ul> <li ms-repeat-e="data">{{e}}</li> </ul> <ul ms-each-e="data"> <li>{{e}}</li> </ul>
Modify the key value of the object:
Modify the object's key value Key-value pair:
Modify the value of the array: array object.set(subscript, value)
Modify the value of the object in the array: array object[subscript].Key name = key value;
Traversal callback function (attribute)
data-each-rendered
data-with-rendered
data-repeat-rendered
data-with-sorted
When looping, use size to calculate the data length, not length, use ms-if-loop instead ms-if, because ms-if takes precedence over ms-repeat execution
11. Template reference
12. Property monitoring
13. Module communication
The following introduces the avalon scope delimitation method
using avalonJS for front-end development When you need to delineate the data binding scope, there are three ways:
(1) ms-controller: This binding attribute will delineate the scope according to the principle of proximity. Start searching online from this tag first
(2) ms-important: This binding attribute only searches for this tag. If the vm binding data cannot be found, it will be output on the page as it is
(3) ms-skip: The function of this binding attribute is to invalidate the data binding, that is The interpolation expression is output as is, regardless of whether the bound data in the scope is found or not

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



How to use WebSocket and JavaScript to implement an online speech recognition system Introduction: With the continuous development of technology, speech recognition technology has become an important part of the field of artificial intelligence. The online speech recognition system based on WebSocket and JavaScript has the characteristics of low latency, real-time and cross-platform, and has become a widely used solution. This article will introduce how to use WebSocket and JavaScript to implement an online speech recognition system.

WebSocket and JavaScript: Key technologies for realizing real-time monitoring systems Introduction: With the rapid development of Internet technology, real-time monitoring systems have been widely used in various fields. One of the key technologies to achieve real-time monitoring is the combination of WebSocket and JavaScript. This article will introduce the application of WebSocket and JavaScript in real-time monitoring systems, give code examples, and explain their implementation principles in detail. 1. WebSocket technology

Introduction to how to use JavaScript and WebSocket to implement a real-time online ordering system: With the popularity of the Internet and the advancement of technology, more and more restaurants have begun to provide online ordering services. In order to implement a real-time online ordering system, we can use JavaScript and WebSocket technology. WebSocket is a full-duplex communication protocol based on the TCP protocol, which can realize real-time two-way communication between the client and the server. In the real-time online ordering system, when the user selects dishes and places an order

How to use WebSocket and JavaScript to implement an online reservation system. In today's digital era, more and more businesses and services need to provide online reservation functions. It is crucial to implement an efficient and real-time online reservation system. This article will introduce how to use WebSocket and JavaScript to implement an online reservation system, and provide specific code examples. 1. What is WebSocket? WebSocket is a full-duplex method on a single TCP connection.

JavaScript and WebSocket: Building an efficient real-time weather forecast system Introduction: Today, the accuracy of weather forecasts is of great significance to daily life and decision-making. As technology develops, we can provide more accurate and reliable weather forecasts by obtaining weather data in real time. In this article, we will learn how to use JavaScript and WebSocket technology to build an efficient real-time weather forecast system. This article will demonstrate the implementation process through specific code examples. We

Usage: In JavaScript, the insertBefore() method is used to insert a new node in the DOM tree. This method requires two parameters: the new node to be inserted and the reference node (that is, the node where the new node will be inserted).

JavaScript tutorial: How to get HTTP status code, specific code examples are required. Preface: In web development, data interaction with the server is often involved. When communicating with the server, we often need to obtain the returned HTTP status code to determine whether the operation is successful, and perform corresponding processing based on different status codes. This article will teach you how to use JavaScript to obtain HTTP status codes and provide some practical code examples. Using XMLHttpRequest

JavaScript is a programming language widely used in web development, while WebSocket is a network protocol used for real-time communication. Combining the powerful functions of the two, we can create an efficient real-time image processing system. This article will introduce how to implement this system using JavaScript and WebSocket, and provide specific code examples. First, we need to clarify the requirements and goals of the real-time image processing system. Suppose we have a camera device that can collect real-time image data
