배열의 경우 vue.js의 기본 배열 메서드가 작동하는 것이 좋습니다 : push, pop, shift, reverse ...하지만 개체에 새 항목을 만들고 일부 값을 붙여 넣는 방법은 무엇입니까?데이터 객체에 새 속성을 추가하는 방법은 무엇입니까?
new Vue({
el: '#demo',
data: {
items: [
{
start: '12:15',
end: '13:15',
name: 'Whatch Vue.js Laracast',
description: 'Watched the Laracast series on Vue.js',
tags: ['learning', 'Vue.js', 'Laracast', 'PHP'],
note: "Vue.js is really awesome. Thanks Evan You!!!"
},
{
start: '13:15',
end: '13:30',
name: "Rubik's Cube",
description: "Play with my Rubik's Cube",
tags: ['Logic', 'Puzzle', "Rubik's Cube"],
note: "Learned a new algorithm."
}
],
},
methods: {
addItemAttribute: function(name, text) {
this.items[0][name] = text;
}
}
});
소품에 객체를 추가하는 방법은 무엇입니까? – Slava
@Slava 조금 설명해 주시겠습니까? 객체를 속성으로 어디에 추가 하시겠습니까? –
모든 구성 요소에는 props 객체 [링크] (http://vuejs.org/api/#props)가 있습니다. 그리고 vue는 $ props 객체를 가지고 있지 않습니다 – Slava