[Vuejs]-Can't get computed to work in a super simple html & js script

0👍

Your code has many errors.

  • data should return an object
  • The computed should be use to display a (formatted) value

Here is you code corrected :

Working codepen : https://codepen.io/Andugal/pen/yLYOmMq?editors=1111

new Vue({
     el :"#app",
     data () {
       return {
         textInput :''
       }
     },
     computed: {
        myFunc : function () {
          return this.textInput
        }
     },
     methods : {
       onInput : function (event) {
         this.textInput = event.target.value;
       }
     }
  });

Leave a comment