D
D
Dauren S2019-01-15 14:14:17
Vue.js
Dauren S, 2019-01-15 14:14:17

Minimum value in vue.js array?

https://codepen.io/anon/pen/REYYyg?editors=1010
There is a first goal, second, third and fourth.
For each goal that is divided into tasks, the user can select a maximum of 100.
How can I make sure that when the choice is less than 100, the submit button (sending the form) does not appear or is not active?
That is, min 100 and max 100. And show that a specific goal is not completely set (by some text message)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2019-01-15
@dauren101

when choosing less than 100, the submit button (submitting the form) did not appear or was not active?

methods: {
  notAchieved(goal) {
    return goal.tasks.reduce((acc, n) => acc + n.value, 0) !== 100;
  },
},
computed: {
  notAllGoalsAchieved() {
    return this.goals.some(this.notAchieved);
  },
},

Where the target names are displayed, add something like
<span v-show="notAchieved(g)">не достигнута</span>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question