Created
May 13, 2021 06:04
-
-
Save nomagick/11d5753a2d87c4ab06702270c1d4a923 to your computer and use it in GitHub Desktop.
Deal with vue computed crap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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