moonjsExamples

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

methods.html (435B)


      1 <body>
      2 <script src="https://unpkg.com/moonjs"></script>
      3 <div id="app3">
      4   <p>{{reverse(msg)}}</p>
      5 </div>
      6 <script>
      7 const app3 = new Moon({
      8   el: "#app3",
      9   data: {
     10     msg: "Hello Moon!"
     11   },
     12   methods: {
     13     changeMessage: function(msg) {
     14       this.set('msg', msg);
     15     },
     16     reverse: function(str) {
     17        return str.split("").reverse().join("");
     18     }
     19   }
     20 });
     21 app3.callMethod('changeMessage', ['New Message!']);
     22 </script>
     23 </body>