S
S
semki0962019-03-06 12:12:53
Vue.js
semki096, 2019-03-06 12:12:53

How to make the user add data himself, vue.js?

For example, there is data

data: {
  colors: [ 'red', 'lime', 'blue', 'yellow', 'black' ],
}

How do we allow the user (for example, by clicking on the palette) to select a color so that the selected color ends up in our array of object colors?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikolai Chuprik, 2019-03-06
@semki096

Just push a new color into the array and that's it:

<div
    style = "background:cyan"
    @click = "colors.push( 'cyan' )">
</div>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question