Vue.js: data 코드의 축약형과 원래 형태 / 배열 특정 원소 대체하기
축약형
1
2
3
4
5
6
7
8
9
export default {
data() {
return {
todoItems: []
}
},
}
1
2
3
4
5
methods: {
addTodo() {
}
},
원래 형태
1
2
3
4
5
6
7
8
9
export default {
data: function(){
return {
todoItems: []
}
},
}
1
2
3
4
5
methods: {
addTodo: function(){
}
},
vue.js vue 축약 원래
1
this.values.splice(index, 1, replacementItem)
1
2
3
4
5
6
7
8
editTodo(keyOfTodoItem, index) {
var edit = prompt(keyOfTodoItem)
localStorage.setItem(keyOfTodoItem, edit)
this.todoItems.splice(index, 1, {
key: keyOfTodoItem,
value: edit
})
}
https://stackoverflow.com/questions/42807888/vuejs-and-vue-set-update-array
This post is licensed under
CC BY 4.0
by the author.