0
const vm = Vue.createApp({

    data(){

        return{
            
            firstname: "tanner",
            lastname: "die"
        }
    },
    methods:{
        fullname(){
            return `${this.firstname} ${this.lastname.toUpperCase()}`
        }
    }

}).mount("#app")
  1. How exactly is data a function was it predefined or does Vue know that its a function.

  2. Is methods an object or a function and if its an object why dont we say {{methods.fullname()}} when were displaying it in HTML.

Tolbxela
  • 4,767
  • 3
  • 21
  • 42
  • 2
    > Under the hood Vue will walk through all the properties that we define into the data and converts them to getter/setters using Object.defineProperty. see [demistyfing vue internals](https://medium.com/js-imaginea/the-vue-js-internals-7b76f76813e3). btw, your fullname is usually declared as a "computed" property. – zangab Apr 11 '23 at 21:34
  • @zangab The comment applies to Vue 2 while the question uses 3 – Estus Flask Apr 12 '23 at 06:52
  • @EstusFlask he uses the options API which afaik didnt change conceptionally. – zangab Apr 12 '23 at 08:01

0 Answers0