A
A
Anton Ivanov2018-02-25 23:01:23
Vue.js
Anton Ivanov, 2018-02-25 23:01:23

How to make behavior definition in vuejs based on class?

Hello.
I continue to master Vue.JS, so the question may be noob and incorrect :)
I have a form that has input fields. On @click (let's say) for each field, I have a specific action. Now the task is to hang one more handler on onfocus. To do this, I will have to manually add @focus="onFocus". But what if there are a lot of input fields? It's inconvenient and inefficient. Using good old jQuery (and vanilla javascript as well) I could hang a handler on all these elements in one line. Doesn't it work with Vue?
Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Shashenkov, 2018-02-26
@Fly3110

Who are refs for?
here as an example

D
Dima Polos, 2018-02-25
@dimovich85

Look at the v-for directive and try it :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question