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

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

问题描述

只是一个简单的问题.

你能强制 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天全站免登陆