D
D
Dilik Pulatov2017-07-26 13:50:01
Vue.js
Dilik Pulatov, 2017-07-26 13:50:01

How to solve a problem in VueJs2?

Hello!
I have a few questions about Vu...those who are pros on Vu, advise the best solution
so
in Vu how to work on elements (like jQuery)
for example
<button @click="myFunc">button</button>

methods:{
  myFunc(e){
    // code
  },
}

inside the myFunc method, how to implement work (changing classes, adding some attributes, etc.) on elements that have an @click attribute
in jQuery, they simply do it with $(this) and that's it ... or will you have to use jQuery functions here? and this one how? (that is, how can you get exactly the element (like jQuery $ (this)) on which we are working)
when working with some data, where to save the best option? in cookies or in localStorage?
for example, I downloaded one template ... and I'm working on it, but if the template has several script files, how can I connect them when working? (the script files contain several functions in jQuery and plugins)
and jQuery is added to my view how to connect them correctly so that there is no problem (sometimes you don’t recognize jQuery and scripts don’t work)
when clicking on the buttons, the class of the element changes, but on all the buttons
, what needs to be done to change the class of only those that we clicked?
<div>
  <myButton @click="isClass = !isClass" :class="{'active':isClass}"></myButton>
  <myButton @click="isClass = !isClass" :class="{'active':isClass}"></myButton>
  <myButton @click="isClass = !isClass" :class="{'active':isClass}"></myButton>
  <myButton @click="isClass = !isClass" :class="{'active':isClass}"></myButton>
</div>

data:{
  isClass: false,
}

For the wound, I'm sorry if somewhere I wrote with an error.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Kulakov, 2017-07-26
@dilikpulatov

1. Access to the dom element:

myFunc(e){
    var element = e.target
  },

2.
when working with some data, where to save the best option? in cookies or in localStorage?
- wherever you want
3.
when clicking on the buttons, the class of the element changes, but on all the buttons
, what needs to be done to change the class of only those that we clicked?

You have one variable, naturally, when it changes, everything changes at once. Possible solutions: create several variables, wrap the button in a component with an internal state. If by pressing the rest are squeezed out, then one variable will suffice.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question