Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
560 views
in Technique[技术] by (71.8m points)

javascript - 您可以强制Vue.js重新加载/重新渲染吗?(Can you force Vue.js to reload/re-render?)

Just a quick question.(只是一个简单的问题。)

Can you force Vue.js to reload/recalculate everything?(您可以强制Vue.js重新加载/重新计算所有内容吗?) If so, how?(如果是这样,怎么办?)   ask by Dave translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Try this magic spell:(试试这个魔术:)

vm.$forceUpdate(); No need to create any hanging vars :)(无需创建任何悬挂变量:)) Update: I found this solution when I only started working with VueJS.(更新:当我仅开始使用VueJS时,我找到了此解决方案。) However further exploration proved this approach as a crutch.(但是,进一步的研究证明了这种方法是拐杖。) As far as I recall, in a while I got rid of it simply putting all the properties that failed to refresh automatically (mostly nested ones) into computed properties.(据我所记得,有一段时间我摆脱了它,只是将所有未能自动刷新的属性(大多数是嵌套属性)放入计算的属性中。) More info here: https://vuejs.org/v2/guide/computed.html(此处提供更多信息: https : //vuejs.org/v2/guide/computed.html)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...