javascript - avalon2, when clicking add, it is required not to add twice.
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-07-05 10:42:37
0
1
665

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>
曾经蜡笔没有小新
曾经蜡笔没有小新

reply all(1)
迷茫

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template