vue强制更新$forceUpdate()

调用强制更新方法this.$forceUpdate()会更新视图和数据,触发updated生命周期。

<template>
<div>
    home
    <button @click="reload()">强制更新</button>
</div>
</template>
<script>
export default {
  name: "Home",
  data () {
    return {
    };
  },
  updated(){
      console.log("更新了");
  },
  methods:{
      reload(){
          this.$forceUpdate();
      }
  }
}
</script>

猜你喜欢

转载自www.cnblogs.com/luguankun/p/10851379.html