VueJs Beginners part 2 – Methods

vuejs-beginners-part-2-–-methods

To add methods to a component instance we use the methods option.
we can define them the way we defined data and indeed methods is a object of functions.

const app = Vue.createApp({
  data() {
    return {
      count: 0
    }
  },
  methods: {
    increment() {
      this.count++
    }
  },
)}

Event and key Modifiers:

It is a very common need to call something like event.preventDefault() inside event handlers. it can be done in method itself but there are some modifiers to apply them easier.

examples:

@click.right
@click.prevent.stop
@keyup.13


 @submit.prevent="onSubmit">


 @keyup.enter="submit" />

do you want more check here

Run and edit them yourself here

Total
3
Shares
Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post
use-nextjs-server-side-pre-rendering-like-a-boss-!

Use NextJS Server Side Pre-Rendering like a boss !🔥

Next Post
who-will-win-the-2022-brazilian-presidential-election?,-according-to-statistics.

Who will win the 2022 Brazilian Presidential Election?, according to statistics.

Related Posts