vue强制更新页面方法总结


1.强制更新,当数据改变了而页面没有改变

this.$set()

this.$forceUpdate()

this.$set()

this.$forceUpdate()

2.watch监听路由,当路由发生变化时,页面没有刷新,可以监听他的路由,当路由发生变化时,刷新页面或者触发动作,使得整个页面刷新

  watch: {
    $route: {
      handler(newVal, oldVal) {
        if (newVal.query.code !== oldVal.query.code)
        或者
        
        newVal.params.id !== odl.params.id
        {
          //调用组价
          // this.$emit("");
          //执行函数
          //this.bindwx();
        }
      }
    }
  }
  
  

子路由触发父路由的方法,如果有多层路由,需要由子路由发出动作再一层一层的传上去,
如孙子路由 this.$emit("updatekeyFn");

<view-router @updatekeyFn="updatekeyFn()"/>
<view-router @updatekeyFn="updatekeyFn()"/>


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM