Menu
My Site LogoMy Site LogoDanyal AsifDocsBlog
GitHub
🌜
🌞
My Site LogoMy Site LogoDanyal Asif
  • Docs
  • Blog
  • GitHub
  • Introduction
  • Certs And Trainings
  • Algorithms & Data Structures
    • Introduction
    • Bubble Sort
  • Containers
    • Basics
    • orchestration
      • Basics
  • CSS
    • Basics
    • SASS
  • DevOps
    • Introduction
    • AWS
    • DevSecOps
  • draft
  • Flutter
    • Flutter basics
    • Flutter
    • Flutter Input
    • Flutter Navigation
    • Flutter Widgets
  • funstuff
    • Advent of Code - 2019
  • Fun Stuff - Programming for fun
  • javascript
    • JavaScript Debugging
    • Filter Object of Objects
    • Introduction
    • Javascript The Hard Parts
    • JavaScript: The New Hard Parts
    • NPM
    • Object-Oriented Programming
    • referrences
    • Typescript Basics and Stuff
    • Filter arrays for unique objects
  • MobX
  • react
    • React Debugging
    • React
  • react-native
    • expo
      • Push Notifications
    • Expo
    • React Native
    • React Navigation (V4)
  • redux
    • Basics
    • Redux Toolkit
    • Redux Saga
    • Thunk
  • VueJs
    • Introduction
    • Vue Methods
  • websockets
    • SignalR
    • WebRTC
  • YAML

Vue Methods

We can attach methods to objects by adding a methods object

So,

new Vue({
el: '#app',
data() {
return {
counter: 0,
x: 0
}
},
methods: {
increment() {
this.counter++; //this refers to current object
},
decrement() {
this.counter--;
}
}
})

and in the HTML, it would be used like:

<div id="app">
<button @click="increment">+</button>
<span> {{ counter }} </span>
<button @click="decrement">-</button>
</div>

Computed properties will be cached after they are computed

Edit this page
Previous
« Introduction
Next
SignalR »

Docs

  • Self Documentation

Community

  • Stack Overflow
  • Discord
  • Twitter

More

  • Blog
  • GitHub
Copyright © 2021 My Project, Inc. Built with Docusaurus.