你能强制Vue.js重新加载/重新渲染吗? [英] Can you force Vue.js to reload/re-render?

查看:168
本文介绍了你能强制Vue.js重新加载/重新渲染吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是一个简单的问题。

Just a quick question.

你能强迫Vue.js重新加载/重新计算一切吗?如果是这样,怎么样?

Can you force Vue.js to reload/recalculate everything? If so, how?

推荐答案

尝试这个魔法咒语:

vm.$forceUpdate();

无需创建任何悬挂变量:)

No need to create any hanging vars :)

更新:当我刚开始使用VueJS时,我找到了这个解决方案。然而,进一步的探索证明这种方法是一种拐杖。据我所知,有一段时间我摆脱它只是将所有无法自动刷新的属性(大多数是嵌套的)放入计算属性中。

Update: I found this solution when I only started working with 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.

此处有更多信息: https:// vuejs.org/v2/guide/computed.html

这篇关于你能强制Vue.js重新加载/重新渲染吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆