Skip to content

Instantly share code, notes, and snippets.

@nomagick
Created May 13, 2021 06:04
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 nomagick/11d5753a2d87c4ab06702270c1d4a923 to your computer and use it in GitHub Desktop.
Save nomagick/11d5753a2d87c4ab06702270c1d4a923 to your computer and use it in GitHub Desktop.
Deal with vue computed crap
// Vue Computed 不行的,不知道定时更新
// 抽他大嘴巴子,给他抽醒
slap(baby: any) {
return this.forceUpdateVueComputedCrap(baby);
}
slapAllTheBabies() {
for (const crap of this.crappyVueBabies) {
this.forceUpdateVueComputedCrap(crap);
}
}
// Shame on Vue, Shame on youyuxi https://github.com/vuejs/vue/issues/214
forceUpdateVueComputedCrap(crap: any) {
setTimeout(() => {
for (const subCrap of Object.values<any>(crap._computedWatchers)) {
subCrap.run();
}
crap.$forceUpdate();
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment