A
A
Alekosh Akhosh2021-09-11 11:54:20
Vue.js
Alekosh Akhosh, 2021-09-11 11:54:20

How to add a letter/characters on click in li?

Couldn't find a solution to this problem. I know zhs on average, but it is unlikely that innerHTML += '!' is used in the view.
How to decide?

Given an array. Print the elements of this array as a ul list. Make it so that when you click on any li, '!' is added to the end of it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2021-09-11
@Akhosh

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

<ul>
  <li
    v-for="(n, i) in items"
    v-text="n"
    @click="$set(items, i, `${n}!`)"
  ></li>
</ul>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question