moonjsExamples

moonjs example (from tutorial)
git clone https://noulin.net/git/moonjsExamples.git
Log | Files | Refs | README

twoWayBinding.html (638B)


      1 <body>
      2 <script src="https://unpkg.com/moonjs"></script>
      3 <div id="app">
      4   <p>{{count}} <input m-model="inputvar"></p>
      5   <button m-on:click="increment">Increment</button>
      6   <button m-on:click="reset">Reset</button>
      7   <p>{{inputvar}}</p>
      8   <div m-if="count !==0">
      9     Count is not 0.
     10   </div>
     11 </div>
     12 <script>
     13 const app7 = new Moon({
     14   el: "#app",
     15   data: {
     16     count: 0,
     17     inputvar: ''
     18   },
     19   methods: {
     20     increment: function() {
     21       // Increment the count by one
     22       this.set('count', this.get('count') + 1);
     23     },
     24     reset: function() {
     25       this.set('count', 0);
     26       this.set('inputvar', '');
     27     }
     28   }
     29 });
     30 </script>
     31 </body>