Whymess
Whymess

Reputation: 717

What does the @ symbol do in Vue.js?

I am new to Vue.js and I am looking at someone's code. I noticed they are using the @ symbol. What does this do and what is it used for?

export default {
  methods: {
    handleCreate() {
      console.log('Child has been created.');
    }
  }
};

<template>
  <ChildComponent @created="handleCreate" />
</template>

// ChildComponent
export default {
  created() {
    this.$emit('created');
  }
}

Upvotes: 23

Views: 16633

Answers (1)

Foxhound
Foxhound

Reputation: 605

In your case, the @ symbol, symbol is shorthand for v-on. It can also be used when importing to resolve things.

Upvotes: 22

Related Questions