码迷,mamicode.com
首页 > 其他好文 > 详细

Vue. 之 刷新当前页面,重载页面数据

时间:2019-08-05 13:37:52      阅读:137      评论:0      收藏:0      [点我收藏+]

标签:http   相同   实现   eth   code   function   The   inf   route   

 Vue. 之 刷新当前页面,重载页面数据

 

如下截图,点击左侧不同的数据,右侧根据左侧的KEY动态加载数据。由于右侧是同一个页面,在进行路由跳转后,不会再次刷新数据。

技术图片

 

  解决方案:

    右侧的页面中 script代码块添加:watch模块,如下代码:

     
     ... ...

     mounted : function() { this.loadData(); }, watch: { //监听相同路由下参数变化的时候,从而实现异步刷新 ‘$route‘(to,from) { this.loadData(); }, }, methods: { loadData() { let varCode = this.$route.query.varCode; this.api.service .gets({ varCode: varCode }) .then(res => { console.log(res) }) },

    ... ...

 

Vue. 之 刷新当前页面,重载页面数据

标签:http   相同   实现   eth   code   function   The   inf   route   

原文地址:https://www.cnblogs.com/Charles-Yuan/p/11302475.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!