R
R
r_g_b_a2020-02-22 16:36:37
Vue.js
r_g_b_a, 2020-02-22 16:36:37

How to display a list of checked checkboxes in vue?

Hello.
There are checkboxes https://jsfiddle.net/c87xnem4/ I want to separately list only those that are checked. The first thought was to use v-for and v-if at the same time, but the documentation says that you should not do this, but you need to create a new calculated property that will return a filtered list. Tell me how it's done?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2020-02-22
@r_g_b_a

computed: {
  done() {
    return this.todos.filter(n => n.done);
  },
},

<ol v-if="done.length">
  <li v-for="n in done" v-text="n.text"></li>
</ol>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question