天天看點

vue keep-alive緩存後,進入緩存頁需要再次更新資料

在keep-alive時

beforeRouteEnter(to, from, next){
    next(vm=>{
        console.log(vm)
        // 每次進入路由執行
        vm.getData()
    })
},
mounted: function () {
    // 隻執行一次的方法
    this.getData()
},