Avalon Video Learning Notes (Fri)

Source: Internet
Author: User

One, insert remove processing 1, binding properties Ms-if
        A, when the value of Ms-if is True (true), the element is output to the page.
 
   
  
  1. <div ms-controller="text">
  2. <div ms-if="true">
  3. 根据条件显示内容
  4. </div>
  5. </div>
 
   
  
  1. <div avalonctrl="test">
  2. <div>
  3. 根据条件显示内容
  4. </div>
  5. </div>
        B, if the value of Ms-if is False (flase), the element is removed from the DOM tree
 
   
  
  1. <div ms-controller="text">
  2. <div ms-if="flase">
  3. 根据条件显示内容
  4. </div>
  5. </div>
 
   
  
  1. <div avalonctrl="test">
  2. <!--ms-if-
  3. </div>
    Avalonctrl is used to find elements for the Avalon garbage collector
<!--ms-if--> is the difference between the 2, Ms-if, and ms-visible that the DOM tree prepares to reload the node of the annotation.
  
 
  1. <meta charset="UTF-8">
  2. <meta name="Generator" content="EditPlus?">
  3. <meta name="Author" content="">
  4. <meta name="Keywords" content="">
  5. <meta name="Description" content="">
  6. <title>avaon-ms-if</title>
  7. <script type="text/javascript" src="../avalon.min.js"></script>
  8. <script type="text/javascript">
  9. avalon.ready(function(){
  10. var vmodel = avalon.define({
  11. $id:‘test‘,
  12. object:{}
  13. });
  14. setTimeout(function(){
  15. vmodel.object = {
  16. id:"123",
  17. message:"显示!!"
  18. }
  19. },3000);
  20. avalon.scan()
  21. });
  22. </script>
  23. <body>
  24. <div ms-controller="test">
  25. 这里是比较输出的结果{{object.id != null}}
  26. <div ms-visible="object.id != null">这里是visible的<span>{{object.message}}</span></div>
  27. <div ms-if="object.id != null">这里是if的<span>{{object.message}}</span></div>
  28. </div>
  29. </body>
* Open the Code debugging tool, you can find that ms-if is not occupied DOM node, is by inserting delete to control the node.
Ms-visible is a DOM node that uses Display:none and display:block to control nodes by adding dynamic styles to the DOM nodes.
Ms-if is more efficient than ms-visible
3, use Ms-if to make toggle tab
  
 
  1. <meta charset="UTF-8">
  2. <meta name="Generator" content="EditPlus?">
  3. <meta name="Author" content="">
  4. <meta name="Keywords" content="">
  5. <meta name="Description" content="">
  6. <title>avalon-ms-if-toggle</title>
  7. <style type="text/css">
  8. div div{
  9. width:200px;
  10. height:100px;
  11. }
  12. div.d1{
  13. background:red;
  14. }
  15. div.d2{
  16. background:green;
  17. }
  18. div.d3{
  19. background:blue;
  20. }
  21. </style>
  22. <script type="text/javascript" src="../avalon.min.js"></script>
  23. <script type="text/javascript">
  24. avalon.ready(function(){
  25. var vm = avalon.define({
  26. $id:‘text‘,
  27. show:1,
  28. but:function(index){
  29. vm.show=index;
  30. }
  31. });
  32. avalon.scan();
  33. })
  34. </script>
  35. <body>
  36. <div ms-controller="text">
  37. <button ms-click="but(1)">红</button>
  38. <button ms-click="but(2)">绿</button>
  39. <button ms-click="but(3)">蓝</button>
  40. <div class="d1" ms-if="show===1"></div>
  41. <div class="d2" ms-if="show===2"></div>
  42. <div class="d3" ms-if="show===3"></div>
  43. </div>
  44. </body>



From for notes (Wiz)

Avalon Video Learning Notes (Fri)

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.