A
A
Anton89892019-11-14 12:14:06
Vue.js
Anton8989, 2019-11-14 12:14:06

How to select text and put it in input?

Good time of the day, there is such a task, please help me solve it, there is a list of products that is displayed on the page through for, when you click on the name of the product, you need to put it in the input, if you click on another product, the name in the input will change to another))

<div>
    <input type="text" >

   <div v-for="phone in phones">
      {{phone}}
    </div>

  </div>

    export default {
        data() {
          return {
              phones: ['iPhone 7', 'Galaxy S8', 'Nokia N8', 'Xiaomi Mi6']
      }
        },

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg Koltunov, 2019-11-14
@Anton8989

<input type="text" v-model="inputPhone">

<div v-for="phone in phones" @click="inputPhone = phone">
      {{phone}}
</div>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question