Why is the function called in the instance created by Vue: not prefixed with methods??

//html
<div id="app">
  

{{ count }}

<button @click="increment">+</button> <button @click="decrement">-</button>

</div>
//js
// make sure to call Vue.use(Vuex) if using a module system

const store = new Vuex.Store({
  state: {
    count: 0
  },
  mutations: {
      increment: state => state.countPP,
    decrement: state => state.count--
  }
})

new Vue({
  el: "-sharpapp",
  computed: {
    count () {
        return store.state.count
    }
  },
  methods: {
    increment () {
      store.commit("increment")
    },
    decrement () {
        store.commit("decrement")
    }
  }
})

in the above code,

<button @click="increment">+</button>
<button @click="decrement">-</button>

Why not methods.increment ()?

Mar.22,2021

because vue does its own processing, it proxies the properties defined in methods to the instance. vue Source code:

clipboard.png

vm is the current instance.

The method in

vue is written in methods. You can write the method name directly when you call it. It is injected internally, for example, you define a string arr, in data and write arr directly instead of methods and data. in data.arr


vue when you write it in the template. These are directly exposed to the vue constructor. When you instantiate, their this points to the object you instantiated, and you directly use this.. Method can be called directly

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3b756-2c28b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3b756-2c28b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?