vue.js 12
<html>
<head>
<title>
test12
</title>
</head>
<body>
<div id="app">
<button @click="issue1">Issue1</button>
<button @click="solution1">Solution1</button>
<button @click="issue2">issue2</button>
<button @click="solution2">Solution2</button>
<div v-for="item in items">
{{item}}
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<script>
new Vue({
el:'#app',
data:{
items:[1,2,3,4,5,6,7,8]
},
methods:{
issue1:function(){
this.items.length = 3; //렌더링 안됨
},
solution1:function(){
this.items.splice(3);
},
issue2:function(){
this.items[2] = 33; //렌더링 안됨
},
solution2:function(){
Vue.set(this.items, 2, 33);
this.items.splice(2,1,33);
}
}
})
</script>
</body>
</html>
댓글
댓글 쓰기