Skip to content

Instantly share code, notes, and snippets.

@acacha
Created September 27, 2019 07:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acacha/a47878f65a3239ae71faa14ca946e473 to your computer and use it in GitHub Desktop.
Save acacha/a47878f65a3239ae71faa14ca946e473 to your computer and use it in GitHub Desktop.
Force update example (Antipattern as 99% of cases is not necessary to rerender manually vue does the job)
Vue.component('ParentA',{
template:`
<div id="parent-a">
<h2>Parent A</h2>
<pre>data {{ this.$data }}</pre>
<button @click="reRender">Rerender Parent</button>
<hr/>
<child-a :score="score"/>
<child-b/>
</div>`,
data() {
return {
score: 100
}
},
methods: {
reRender() {
this.$forceUpdate();
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment