-
Notifications
You must be signed in to change notification settings - Fork 3
Update events.md #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update events.md #11
Conversation
src/v2/guide/events.md
Outdated
@@ -4,18 +4,19 @@ type: guide | |||
order: 9 | |||
--- | |||
|
|||
<div class="vueschool"><a href="https://vueschool.io/lessons/vuejs-user-events?friend=vuejs" target="_blank" rel="sponsored noopener" title="Learn how to handle events on Vue School">Learn how to handle events in a free Vue School lesson</a></div> | |||
<div class="vueschool"><a href="https://vueschool.io/lessons/vuejs-user-events?friend=vuejs" target="_blank" rel="sponsored noopener" title="Дізнайся, як обробляти події на безкоштовному уроці Vue School">Дізнайся, як обробляти події на безкоштовному уроці Vue School</a></div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ми скрізь вживаємо "Дізнайтеся"
src/v2/guide/events.md
Outdated
|
||
## Listening to Events | ||
## Прослуховування подій | ||
|
||
We can use the `v-on` directive to listen to DOM events and run some JavaScript when they're triggered. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Прохання видалити оригінал тут, та нижче
src/v2/guide/events.md
Outdated
|
||
The logic for many event handlers will be more complex though, so keeping your JavaScript in the value of the `v-on` attribute isn't feasible. That's why `v-on` can also accept the name of a method you'd like to call. | ||
Однак логіка для багатьох обробників подій буде більш складною, тому записати ваш JavaScript у значення атрибута `v-on` неможливе. Ось чому v-on також може прийняти назву методу, який ви хочете викликати. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Відсутня кома після "однак"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Насправді, це можливо, але так робити не варто. Я б переклав як
.... тому зберігати JavaScript-код в якості значення атрибута
v-on
не підходить. Ось чому ... може ПРИЙМАТИ ....
src/v2/guide/events.md
Outdated
|
||
For example: | ||
На приклад: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Наприклад:" - разом. Або ж виправити на "Спробуємо на прикладі:"
src/v2/guide/events.md
Outdated
|
||
``` html | ||
<div id="example-2"> | ||
<!-- `greet` is the name of a method defined below --> | ||
<button v-on:click="greet">Greet</button> | ||
<!-- `greet` є ім'ям методу визначеного нижче --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
після "методу" відсутня кома
src/v2/guide/events.md
Outdated
<!-- `greet` is the name of a method defined below --> | ||
<button v-on:click="greet">Greet</button> | ||
<!-- `greet` є ім'ям методу визначеного нижче --> | ||
<button v-on:click="greet">Чудово</button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greet - Привітати
Great - Чудово
src/v2/guide/events.md
Outdated
}, | ||
// define methods under the `methods` object | ||
// визначити метод в об'єкті "методи" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
визначити метод в об'єкті методів
або
визначити метод в об'єкті "methods"
src/v2/guide/events.md
Outdated
|
||
{% raw %} | ||
<div id="example-2" class="demo"> | ||
<button v-on:click="greet">Greet</button> | ||
<button v-on:click="greet">Чудово</button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Привітати
src/v2/guide/events.md
Outdated
<button v-on:click="say('hi')">Say hi</button> | ||
<button v-on:click="say('what')">Say what</button> | ||
<button v-on:click="say('Привіт')">Скажи привіт</button> | ||
<button v-on:click="say('Що')">Скажи що</button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Say hi"
"Say what"
→
"Сказати привіт"
"Сказати що?"
src/v2/guide/events.md
Outdated
</div> | ||
``` | ||
|
||
``` js | ||
var example2 = new Vue({ | ||
el: '#example-2', | ||
data: { | ||
name: 'Vue.js' | ||
name: 'Vue.js', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ми не можемо міняти форматування коду, можемо робити лише переклад
src/v2/guide/events.md
Outdated
// `this` inside methods points to the Vue instance | ||
alert('Hello ' + this.name + '!') | ||
// `event` is the native DOM event | ||
greet(event) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ми не можемо міняти форматування коду і переводити його на es6. Він навмисно був написаний в es5 режимі. Прохання повернути форматований та переведений на es6 код назад на оригінальний
src/v2/guide/events.md
Outdated
} | ||
} | ||
``` | ||
|
||
## Event Modifiers | ||
## Модифікатори подій | ||
|
||
It is a very common need to call `event.preventDefault()` or `event.stopPropagation()` inside event handlers. Although we can do this easily inside methods, it would be better if the methods can be purely about data logic rather than having to deal with DOM event details. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
залишки оригіналу
src/v2/guide/events.md
Outdated
To address this problem, Vue provides **event modifiers** for `v-on`. Recall that modifiers are directive postfixes denoted by a dot. | ||
Часто є необхідність викликати `event.preventDefault()` або `event.stopPropagation()` всередині обробників подій. Незважаючи на те, що ми можемо зробити це легко всередині методів, було б краще, якщо б методи використовували виключно логіку даних, а не мали справу з деталями подій DOM. | ||
|
||
Для вирішення цієї проблеми Vue надає **модифікатори подій** для `v-on`. Нагадаємо, що модифікатори - це директивні постфікси, позначені крапкою. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
директивні постфікси, розділені крапкою
src/v2/guide/events.md
Outdated
<a v-on:click.once="doThis"></a> | ||
``` | ||
|
||
Unlike the other modifiers, which are exclusive to native DOM events, the `.once` modifier can also be used on [component events](components-custom-events.html). If you haven't read about components yet, don't worry about this for now. | ||
На відміну від інших модифікаторів, які є лише для власних подій DOM, модифікатор `.once` також може використовуватися на [компонентах подій] (components-custom-events.html). Якщо ви ще не читали про компоненти, наразі не хвилюйтеся про це. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
лишній пробіл перед відкриваючою круглою дужкою
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
пропоную перекласти "компонентах подій" на "спеціальні події", оскільки ця фраза містить посилання на одноіменний розділ https://vuejs.org.ua/v2/guide/components-custom-events.html
src/v2/guide/events.md
Outdated
<input v-on:keyup.enter="submit"> | ||
``` | ||
|
||
You can directly use any valid key names exposed via [`KeyboardEvent.key`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values) as modifiers by converting them to kebab-case. | ||
Ви можете безпосередньо використовувати будь-які дійсні імена ключів, визначені у [`ПодіїКлавіатури.клавіші`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values) як модифікатори перевівши їх у kebab-case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
KeyboardEvent.key
не вимагає перекладу, оскільки це існуюче ім'я об'єкту
src/v2/guide/events.md
Outdated
|
||
- `.enter` | ||
- `.tab` | ||
- `.delete` (captures both "Delete" and "Backspace" keys) | ||
- `.delete` (перехоплює як клавіші "Delete" так і "Backspace") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
перед "так" відсутня кома
src/v2/guide/events.md
Outdated
|
||
### `.exact` Modifier | ||
### `.exact` Модифікатор |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.exact
модифікатор
або
Модифікатор
.exact
src/v2/guide/events.md
Outdated
<button v-on:click.exact="onClick">A</button> | ||
``` | ||
|
||
### Mouse Button Modifiers | ||
### Модифікатори клафіш миші |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
клавіш
src/v2/guide/events.md
Outdated
|
||
You might be concerned that this whole event listening approach violates the good old rules about "separation of concerns". Rest assured - since all Vue handler functions and expressions are strictly bound to the ViewModel that's handling the current view, it won't cause any maintenance difficulty. In fact, there are several benefits in using `v-on`: | ||
Ви можете бути стурбовані тим, що весь цей підхід до прослуховування подій порушує старі добрі правила щодо "відокремлення проблем". Будьте впевнені - оскільки всі функції та вирази обробника Vue суворо пов’язані з ViewModel, який обробляє поточний вигляд, це не спричинить труднощів з технічним обслуговуванням. Насправді використання "v-on" має кілька переваг: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Після "Насправді" відсутня кома
src/v2/guide/events.md
Outdated
|
||
1. It's easier to locate the handler function implementations within your JS code by skimming the HTML template. | ||
1. Простіше знайти реалізації функції обробника в коді JS, обробивши шаблон HTML. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не дуже зрозумілий переклад. Як щодо
Простіше знайти функцію-обробник події у вашому JS коді простим переглядом HTML шаблону.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see the comments above
Fixes #9 |
Note
We're currently in the process of migrating Vue's documentation to v3. To ensure smooth progress, only PR's that fix critical bugs and/or misinformation will be accepted. If yours is not one of them, consider creating an issue instead and we will label it as
post-3.0
for later tackling.