Vue 2.0 Issue
How to update data without component update?
by simati
HTML
<script src="https://unpkg.com/vue"></script>
<div id="app">
<div>
<button @click="changeNode">
change node
</button>
<button @click="changeData">
change data
</button>
<button @click="reset">
reset
</button>
</div>
<div class="container">
<div>
<h2>Actual node</h2>
<div class="wrap">
<p v-for="item in items">
{{ item }}
</p>
</div>
</div>
<div>
<h2>Actual data</h2>
<pre>{{ items }}</pre>
</div>
</div>
</div>
CSS
.container {
display: flex;
flex-direction: row;
}
.container div {
margin-left: 15px;
}
JavaScript
new Vue({
el: '#app',
data: {
items: [1, 2, 3]
},
methods: {
changeNode () {
const node = document.querySelector('.wrap')
const first = node.firstChild
const third = node.lastChild
node.insertBefore(third, first)
},
changeData () {
},
reset () {
this.items = [1, 2, 3]
}
},
mounted () {
console.log(this)
}
})