search

Home  >  Q&A  >  body text

javascript - avalon2, when clicking add, it is required not to add twice.

Asking for a sample code:
Write an example according to the ???? area code format, (ms-for, ms-visible, ms-if) position cannot be changed, cannot be increased or decreased , When you click Add, it will not be added twice.
Or is there something wrong with my way of writing?

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
<!--<script src="avalon2.js"></script>-->
    <script src="https://unpkg.com/avalon2@2.2.8/dist/avalon.js"></script>
</head>
<body>
<p id="floor" ms-controller="floor">
    <button ms-click="add_floor()" >添加1</button>
    
    <!--???????-->
    <p class="floor" ms-for="el in @items" ms-visible="1<2">
        <p class="type1"  ms-if="1<2">
            sssssss
        </p>
    </p>
    <!--???????-->
</p>
<script>
    var floors = avalon.define({
        $id       : 'floor' ,
        items     : [],
        add_floor : function(){
            floors.items.push('');
        }
    })
</script>
</body>
</html>
曾经蜡笔没有小新曾经蜡笔没有小新2727 days ago650

reply all(1)I'll reply

  • 迷茫

    迷茫2017-07-05 10:44:37

    should be

    <p class="type1"  ms-if="1<2">
      sssssss
    </p>

    The problem with ms-if here can be changed to ms-visible or removed without any problem.

    reply
    0
  • Cancelreply