xia0ta0
V2EX  ›  Vue.js

浏览器点击后退,怎样更新 Vue 的组件状态?

  •  
  •   xia0ta0 · Aug 23, 2016 · 11223 views
    This topic created in 3737 days ago, the information mentioned may be changed or developed.
    现在网站的首页有一个用户消息提示,用户点击后会查看消息。但是当用户后退到首页,消息提示还在。只有刷新页面才能消除。

    请问在哪个生命周期里进行设置?
    6 replies  •  2016-08-24 09:34:14 +08:00
    des
    des
    Aug 23, 2016 via Android❤️1
    1
    监听 popstate 事件,然后主动刷新?
    shyling
    shyling
    Aug 23, 2016❤️1
    2
    在 route:{
    data:{初始化消息提示为隐藏状态}
    }
    airyland
    airyland
    Aug 23, 2016❤️1
    3
    点击后为什么不清除掉。。
    xia0ta0
    xia0ta0
    OP
    Aug 23, 2016
    4
    @des 感觉有点不 Vue ...

    @shyling 现在是在一个 component 里, route 方法好像不起作用


    @airyland 想找到一个通用的浏览器后退,页面状态刷新方案
    shyling
    shyling
    Aug 23, 2016
    5
    @xia0ta0 试试 ready ,不然就在外部 component 传 not show 的 prop , vuex 什么的咯
    xia0ta0
    xia0ta0
    OP
    Aug 24, 2016
    6
    @shyling 嗯,看来要放到 store 了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   3167 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 10:13 · PVG 18:13 · LAX 02:13 · JFK 05:13
    ♥ Do have faith in what you're doing.