Answer the question
In order to leave comments, you need to log in
What do the three dots mean in this case: ...mapMutations({ (listing in the body of the question)?
Here:
<script>
import { mapMutations } from 'vuex'
export default {
computed: {
todos () { return this.$store.state.todos.list }
},
methods: {
addTodo (e) {
this.$store.commit('todos/add', e.target.value)
e.target.value = ''
},
...mapMutations({
toggle: 'todos/toggle'
})
}
}
</script>
Answer the question
In order to leave comments, you need to log in
Spread Operator is syntactic sugar for Object.create. As a result of use, a copy of the operand object will be created, in this case the object returned by the mapMutations function.
Examples:
// Только для примера, в жизни для этой задачи использовать .map
[1, 2, 3].reduce((acc, el) => [...acc, el ** 2], [])
const o = {
importantField: “value”,
some: true,
random: false,
stuff: null
}
const { importantField, ...someRandomStuff } = o
// Не совсем тоже самое, но спред используется и здесь
function variadicFn(singleArg, ...arrayWithTheRestOfArgs) {}
const condition = true
const p = { ...condition && { text: “Contion is truthful” } }
The new operator ... is called spread (spread, expansion) or rest (remainder) depending on where and how it is used.
es6
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question