M
M
msdoc112020-08-21 16:44:17
Vue.js
msdoc11, 2020-08-21 16:44:17

How to pass data-value on click to a specific location?

<input type="text" value="Сюда">

<label data-value="Название"></label>


How to correctly pass attribute values ​​on click. For example, extract the value of the attribute from the label and pass it to the value of the input

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2020-08-21
@msdoc11

There is no need to pass any attribute values ​​anywhere, this is not how things are done in vue. Let the current and possible values ​​be properties of the component, and assign one to the other on click:

data: () => ({
  value: '',
  values: [ 'hello, world!!', 'fuck the world', 'fuck everything' ],
}),

<input v-model="value">
<button v-for="(n, i) in values" @click="value = n">set value #{{ i + 1 }}</button>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question