# vm.$emit( eventName, \[…args] )

**Аргументы:**

* `{string} eventName`
* `[...args]`

Порождает событие в текущем экземпляре. Все дополнительно указанные параметры будут переданы в коллбэк подписки.

**Примеры:**

Использование `$emit` только с именем события:

```javascript
Vue.component('welcome-button', {
  template: `
    <button v-on:click="$emit('welcome')">
      Нажмите для приветствия
    </button>
  `
})
```

```markup
<div id="emit-example-simple">
  <welcome-button v-on:welcome="sayHi"></welcome-button>
</div>
```

```javascript
new Vue({
  el: '#emit-example-simple',
  methods: {
    sayHi: function () {
      alert('Привет!')
    }
  }
})
```

Использование `$emit` с дополнительными аргументами:

```javascript
Vue.component('magic-eight-ball', {
  data: function () {
    return {
      possibleAdvice: ['Да', 'Нет', 'Может быть']
    }
  },
  methods: {
    giveAdvice: function () {
      var randomAdviceIndex = Math.floor(Math.random() * this.possibleAdvice.length)
      this.$emit('give-advice', this.possibleAdvice[randomAdviceIndex])
    }
  },
  template: `
    <button v-on:click="giveAdvice">
      Делать или нет?
    </button>
  `
})
```

```markup
<div id="emit-example-argument">
  <magic-eight-ball v-on:give-advice="showAdvice"></magic-eight-ball>
</div>
```

```javascript
new Vue({
  el: '#emit-example-argument',
  methods: {
    showAdvice: function (advice) {
      alert(advice)
    }
  }
})
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://d-ukolov.gitbook.io/vue/komponenty/polzovatelskie-sobytiya/generaciya-polzovatelskikh-sobytii/vm.usdemit-eventname-...args.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
